Hi All
Newbie to Appian.
Trying to find, by date & time, the latest (most recently uploaded) document in a folder; this is as far as I have got in an expression I am playing around with:
a!forEach(
items: folder(1234, "documentChildren"),
expression: document(fv!item, "dateCreated")
)
Any good examples to help me finish this off, or can anyone suggest how to loop through each document and return the newest?
Example Algorithm in pseudo code I would like translated to Appianese.
MostRecentlyUploaded = initial ‘zero date’
For Each Documents Creation Date
If Documents Creation Date > MostRecentlyUploaded Then
MostRecentlyUploaded = Documents Creation Date
End if
End For
Return MostRecentlyUploaded /* The most recent date */
Thanks
Daniel
Discussion posts and replies are publicly visible
The document ID will always be incremental as Amaan mentioned and can be relied on. But here is an alternate approach with one of my favorite functions - displayValue() using the created date attribute
a!localVariables( local!documents: a!forEach( items: folder(5, "documentChildren"), expression: a!map( id: document(fv!item, "id"), dateCreated: document(fv!item, "dateCreated") ) ), local!maxDate: max(local!documents.dateCreated), displayvalue( local!maxDate, local!documents.dateCreated, local!documents.id, {} ) )
Thanks Harshit, works nicely!!