Fetch date last uploaded document in a specific folder
If you need to know the date the last document was uploaded in a folder:
the example below return this form the selected Category (this is a document part 'Doc_Category') of the value : 'J1. Annual progress report'
var serviceGuid = #REPLACE-VARIABLE-1550-ServiceGUID#; var serviceDetails = JSON.parse(ServiceCatalogInterface.getServiceDetail(serviceGuid, { LoadRelations: false, LoadParts: false, PartsUseValue: true })); var annualreportdates = serviceDetails.documents.filter(function (doc) { return doc.parts.filter(function (docpart) { return docpart.internalname === "Doc_Category"; }).map(function (docpart) { return docpart.value; }).join("") === "J1. Annual progress report"; }).map(function (doc) { return doc.date; }) if (annualreportdates.length > 0) { annualreportdates.sort(); return CommonInterface.utcDateToString(new Date(annualreportdates[annualreportdates.length - 1]), "yyyyMMddHHmmss"); } return "";
If you know compare this value against the current date, you know the difference in days.
It will return the number of days since the last upload.
DATEDIFF(todate('#REPLACE-VARIABLE-1680-Date_Last_Report J1#'),todate('#REPLACE-GENERAL-CurrentDate-yyyyMMdd#'), 'D')