> For the complete documentation index, see [llms.txt](https://gebra-it.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gebra-it.gitbook.io/wiki/client-api-reference/functions/getattachmentsforcurrentrecord.md).

# getAttachmentsForCurrentRecord

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

## Example Usages

### Example 1

```javascript
console.log(app.getAttachmentsForCurrentRecord());
```

### Example 2 Filtering

```javascript
let allAttachmentsForThisRecord = app.getAttachmentsForCurrentRecord();
let invoices = allAttachmentsForThisRecord.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 the current record. The list is sorted in descending order based on the id properties of the attachments. If there are no attachments found for the current record, it still returns an empty array. Recall that an empty array is not equal to null.
