Any alternative for findfoldersbyname()

Hi Everyone,

Please suggest me alternative for findfoldersbyname() function.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    In addition to what said, can you tell us more about why you need an alternative function?
  • 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
      )
    )

Reply
  • 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
      )
    )

Children
No Data