I have requirement to get the no of documents created last day/yesterday in KC.
We have a function to get the number of documents present in KC : knowledgecenter(ri!folderId,"numberOfDocuments")
Can anyone please how to approach. Thanks in advance
Discussion posts and replies are publicly visible
a!localVariables( local!document: folder( cons!LSME_DOCUMENT_FOLDER, "documentChildren" ), local!dateCreated: a!forEach( items: local!document, expression: if( todate(document(fv!item, "dateCreated")) > today()-1, true(), false() ) ), length( remove( local!dateCreated, wherecontains(false(), local!dateCreated) ) ))
Thank you Prafuls0004. This solves my query
An alternative approach
a!localVariables( local!document: folder( cons!LSME_DOCUMENT_FOLDER, "documentChildren" ), sum( a!forEach( items: local!document, expression: todate(document(fv!item, "dateCreated")) > today()-1, ) ) )
When converting a boolean value into an integer, it becomes 0 for false and 1 for true. We can use that to calculate the sum of true values in a boolean list.
BTW, a comparison always evaluates to a boolean. Putting it into an if() will not make this a more elegant implementation.