Skip to content

Adding Attachments Lazily (V1) (persistent.addAttachmentsLazyV1)

You can use persistent.addAttachmentsLazyV1 to add one or more attachments to existing documents using an older parameter format. This function internally maps these parameters to the format expected by persistent.addAttachmentsLazy.

Syntax

persistent.addAttachmentsLazyV1(attachmentsArray);

Parameters

The addAttachmentsLazyV1 function takes a single parameter, which must be an array of objects. Each object in the array represents an attachment to be added and must have the following properties:

Parameter Type Required Description
ddName String Yes The name of the document definition to which the document belongs. If the value is null, BizzStream will use the name of the document from which the script was started.
_id String No, either the _id or externalId field should be supplied. The internal ID of the document to which the attachment should be added.
externalId String No, either the _id or externalId field should be supplied. The external ID of the source document.
fieldName String Yes The name of the field to which the attachment has to be added. (This parameter is mapped to valuePath internally).
lineName String No If the attachment field is part of a line, enter the name of the line here.
lineId String No The ID of the line from which the attachments should be added.
lineExternalId String No, if the lineName field has a value, either the lineId or lineExternalId should be entered. The external ID of the line from which the attachments should be added.
fileName String Yes The name of the file that is added. For example: 'image01.png' or 'image02.jpg' or 'file03.pdf'
Content String Yes A Base64 string that represents the content. It is recommended to include a prefix for the MIME type, for example: 'data:image/jpeg;base64,'+LONG_STRING. If this string does not contain a MIME type, Bizzstream tries to add it based on the extension of the file.

Return value

Does not return anything, undefined.

Example

The following example shows how to add a single attachment using persistent.addAttachmentsLazyV1 with the older parameter format:

persistent.addAttachmentsLazyV1([
  {
    ddName: 'reports',
    _id: 'report_abc123',
    fieldName: 'reportImage',
    fileName: 'report_image.png',
    Content: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg....', // Base64 content here
  }
]);