Hi Everyone,
Please suggest me alternative for findfoldersbyname() function.
Discussion posts and replies are publicly visible
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
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 ) )