Any alternative for findfoldersbyname()

Hi Everyone,

Please suggest me alternative for findfoldersbyname() function.

  Discussion posts and replies are publicly visible

  • Hi Mohammed,

    If you maintain folder in constant, you can use
    getcontentobjectdetailsbyid(cons!FOLDER) or
    folder(cons!FOLDER, "name")
    otherwise you need to use "Custom Content Functions" Plug-In

    Frankly, i am not getting any other way (may be morning coffee not working ;)).
    lets see if any fellow practitioner know any alternative.
  • 0
    Certified Lead Developer
    In addition to what said, can you tell us more about why you need an alternative function?
  • Extracted from below link:

    UPDATED 28 Sept 2015 findFoldersByName: Deprecated due to edge cases where search would not return expected results and adjusting this specific function would break backwards compatibility. Existing implementations of this function will continue to execute but this function is now hidden from the expression editor palette. findContentByAttribute: Added to replace and improve upon functionality provided by findFoldersByName. Allows for searching for content (folders, documents) by attribute - valid values are "name", "author", "description" (Document only), "extension" (Document only)

     Link: forum.appian.com/.../summary

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    The functions findFoldersByName and findDocumentByName don't scale once you have hundreds of thousands of documents - I've seen returns from these functions of 7 or more seconds; pretty bad.

    The short answer is store the folder and/or document ID in the database. However, if you absolutely must retrieve, for example, the documents within a folder, it's possible to write an expression that does something similar - see below. Note that the same principle can be applied to finding a folder by name within a specific folder.

    load(
      local!allFolderDocuments: fn!getdocumentsfromfolder(
        ri!folder,
        false
      ),
      local!allFolderDocumentNames: a!forEach(
        items: local!allFolderDocuments,
        expression: document(
          fv!item,
          "name"
        )
      ),
      index(
        index(
          local!allFolderDocuments,
          wherecontains(
            ri!documentName,
            local!allFolderDocumentNames
          ),
          tointeger(
            {}
          )
        ),
        1,
        null
      )
    )

  • Thanks for responding, Actually contentfunctions plugin is deprecated hence I need any alternative for findfoldersbyname() function.

    To specify more about my requirement, end users of my application upload some documents while raising a request, during the flow we are creating a folder with name as ID of this request and we will be storing the documents in this folder and data is stored in DB but we are not capturing the folder ID in DB.

    Further more to this request we have a related action wherein user can upload more documents to this folder, so in this scenario the process model of the related action will be having only folder name taken from rf!requestID, so I need to identify the folder by its name so that the further uploaded documents to be stored in the correct folder.
  • I would recommend to store the folder id against unique id ( requestId in your case) in a separate table. We did the same in our implementation.

    Regards
    Bala K
  • Thanks everyone for your response.

    I have achieved the requirement with help of my colleague. Here the constant is holding the parent folder whit in which we are creating the new folders for every new request, and rule input is we are passing the folder name that we want to search.

    with(
    local!allFolderId:tointeger(
    folder(tointeger(cons!GOE_UPLOAD_DOCUMENT_FOLDER),"folderChildren")
    ),
    local!folderName:apply(
    folder(
    folderId :_,
    property :"name"
    ),
    local!allFolderId
    ),
    index(
    local!allFolderId,
    wherecontains(
    ri!folderName,
    local!folderName
    )

    )
    )