getAttachmentsForRecord

Returns a list of all the attachments of a record. The list is ordered by id desc. so the newest documents will be the first you will find while iterating over the array.

Parameters

appName - The name of the app you are looking for

recordId - The record id you want to filter

Example Usages

Example 1

console.log(app.getAttachmentsForRecord("customerOrder", 123));

Example 2 Filtering

let allAttachmentsForRecord = app.getAttachmentsForRecord("customerOrder", 123);
let invoices = allAttachmentsForRecord.filter((singleAttachment) => {
  return singleAttachment.documentTypeId == 2;
}); 
//We assume, that there is just one invoice
let attachmentBlob = app.getAttachmentById(invoices[0].id);
app.printBlob(attachmentBlob);

Return Values

The function returns a sorted list of attachments for a record. The list is sorted in descending order based on the id properties of the attachments. If there are no attachments found for the record, it still returns an empty array. Recall that an empty array is not equal to null.

Last updated

Was this helpful?