accessing createdOn date
I have a workflow that creates Excel spreadsheets. No problem there.
Now, when I run the workflow I need to delete any files that are more than 30 days old before I create the new spreadsheet.
I can get all the files with a certain string int he name, but I can’ get the createdOn date.
listOfFiles = attachmentApi.findAttachments(FindAttachmentsRequest.builder()
.baseResourceId([UUID.fromString(“9f7b290d-8d1e-4307-b96a-fbdd085f172b”)]) //data dictionaries community
.build())
.getResults()
loggerApi.info("Files : " + listOfFiles)
// – set the date for deletion to today - 30 days
def deleteDate = startDate.minus(30)
loggerApi.info(“Delete Date:” + deleteDate.toString())
for (file in listOfFiles)
{
fileId = file.getFile().getId().toString()
loggerApi.info("File ID: " + fileId)
fileName = file.getFile().getName()
loggerApi.info("File Name :" + fileName)
//fileUploadDate = file.Resource().getCreatedOn()
if (fileName.contains("Technical Asset Activity"))
{
//loggerApi.info("directory file : " + fileName + "Created On : " + fileUploadDate.toString())
//if (file.uploadDate <= fileUploadDate)
//{
//file.delete()
//}
}
}
As you can see here, there is a createdOn date in the Resources area, but I can’t seem to get to it. I have no trouble getting to file.Name
Attachment{baseResource=ResourceReferenceImpl{id=9f7b290d-8d1e-4307-b96a-fbdd085f172b, resourceType=Community}, file=FileReferenceImpl{id=f1ab9a0d-8eca-4bb7-aa81-2cfc11f32f73, name=‘Technical Asset Activity from Thu Jan 12 05:03:57 PST 2023.xls’, contentType=‘application/vnd.ms-excel’}} Resource{createdBy=33308db0-a0ad-4333-a537-064a5852de36, createdOn=1674141016622, lastModifiedBy=33308db0-a0ad-4333-a537-064a5852de36, lastModifiedOn=1674141016625, system=false, resourceType=Attachment} EntityImpl{id=6c45a139-de76-48cd-8eab-0fa07351571d},
arthurburkhardt
·3 years ago · Editedor you can use chatGPT
michaelwalter
OP3 years ago · EditedThat worked! You guys are the best. Now to convert to a “real” date.
arthurburkhardt
·3 years ago · EditedYeah… I don’t know what happened there.
arthurburkhardt
·3 years ago · EditedThis is why autocomplete with the groovy APIs is a godsend
: The best autocomplete trick for eclipse! Get hints to java apis directly. -
Product Q&A - the Data Citizens community (collibra.com)

alvinuseree
·3 years ago · Edited++ 🫶
Absolutely, I revisited the Java API documentation recently and was a bit disappointed at how unintuitive it’s become … as an example many of the Public interface links lead to 404 pages lol
alvinuseree
·3 years ago · EditedI see the confusion, in the documentation it says that the createdOn method is inherited from the Resource class.
This means you can call the method directly from the attachment class I.e you don’t need to reference Resource itself.
This should work:
fileUploadDate = file.getCreatedOn()