Skip to main content

downloadAttachments

This function downloads multiple attachments combined into a single ZIP file. It's useful for providing users with a convenient way to download multiple documents at once.

Syntax

app.downloadAttachments(downloadOptions)

Parameters

ParameterTypeDescription
downloadOptionsObjectConfiguration options for the download
downloadOptions.requestedIdsArrayArray of attachment IDs to be included in the ZIP file
downloadOptions.fileNameString(Optional) Custom name for the downloaded ZIP file. If not provided, a default name will be used

Return Value

This function doesn't return a value. It initiates a file download in the browser when executed.

Examples

Example 1: Download multiple attachments with default filename:

// Download attachments with IDs 196, 197, and 200
app.downloadAttachments({
requestedIds: [196, 197, 200]
});

Example 2: Download multiple attachments with custom filename:

// Download attachments with IDs 196, 197, and 200 and specify the filename
app.downloadAttachments({
requestedIds: [196, 197, 200],
fileName: "ProjectDocuments.zip"
});

Example 3: Download all attachments for the current record:

// First get all attachments for the current record
const attachments = await app.getAttachmentsForCurrentRecord();
// Then download all attachments by extracting their IDs
app.downloadAttachments({
requestedIds: attachments.map(a => a.id),
fileName: "AllDocuments.zip"
});

Notes

  • This function works asynchronously, but you don't need to await it since it triggers a browser download.
  • The file will be downloaded using the browser's standard download mechanism.
  • File names in the ZIP will match the original attachment file names.
  • For downloading a single attachment, consider using the downloadAttachment(attachmentId) function instead.