Hi folks,
I have the following code but I need to sort the files by the latest created on date. I have tried but it gives a datatype error.
load( local!data: { { id: 1,folderId:ri!folderId/* Folder ids*/ } }, local!doc: tointeger( a!forEach( items: index( local!data, "folderId", {} ), expression: folder( fv!item, "documentChildren" ) ) ), local!pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 10 ), with( local!currentData: todatasubset( local!doc, local!pagingInfo ), a!gridField( label: "", labelPosition: "ABOVE", totalCount: if( rule!Utils_CheckIsNull( local!doc ), 0, length( local!doc ) ), columns: { a!gridTextColumn( label: "Document", data: a!forEach( items: local!currentData, expression: document( fv!item, "name" ) ), links: a!forEach( items: local!currentData, expression: a!documentDownloadLink( document: fv!item ) ) ), a!gridTextColumn( label: "Version", data: a!forEach( items: local!currentData, expression: document( fv!item, "totalNumberOfVersions" ) ) ), a!gridTextColumn( label: "Uploaded By", data: a!forEach( items: local!currentData, expression: document( fv!item, "lastUserToModify" ) ) ), a!gridTextColumn( label: "Created On", data: a!forEach( items: local!currentData, expression: document( fv!item, "dateCreated" ) ) ) }, saveInto: local!pagingInfo, value: local!pagingInfo ) ))
Any help would be appreciated. TIA!
Discussion posts and replies are publicly visible
Hi,
Please find the below code with sorting.
load( local!data: { { id: 1, folderId: ri!folderId } }, local!doc: tointeger( a!forEach( items: index( local!data, "folderId", {} ), expression: folder( fv!item, "documentChildren" ) ) ), local!docData: a!forEach( local!doc, { doc: fv!item, name: document( fv!item, "name" ), version: document( fv!item, "totalNumberOfVersions" ), uploadedBy: document( fv!item, "lastUserToModify" ), createdDate: document( fv!item, "dateCreated" ) } ), local!pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 10, sort: a!sortInfo( field: "createdDate", ascending: true() ) ), with( local!currentData: todatasubset( local!docData, local!pagingInfo ), a!gridField( label: "", labelPosition: "ABOVE", totalCount: if( rule!APN_isBlank( local!doc ), 0, length( local!doc ) ), columns: { a!gridTextColumn( label: "Document", data: index( local!currentData.data, "name", "" ), links: a!forEach(index( local!currentData.data, "doc", "" ),a!documentDownloadLink(fv!item)) ), a!gridTextColumn( label: "Version", data: index( local!currentData.data, "version", "" ) ), a!gridTextColumn( label: "Uploaded By", data: index( local!currentData.data, "uploadedBy", "" ) ), a!gridTextColumn( label: "Created On", field: "createdDate", data: index( local!currentData.data, "createdDate", "" ) ) }, saveInto: local!pagingInfo, value: local!pagingInfo ) ) )