Adding attachments (persistent.addAttachmentsLazy)
You can add files to attachment fields using a script method.
You can use persistent.addAttachmentsLazy to add an attachment.
persistent.addAttachmentsLazy([{content}]);
Content 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. |
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. |
Example
persistent.addAttachmentsLazy([{
'fieldName': 'attachment',
'lineName': 'orderLines',
'lineId': '1234',
'_id': '12345',
'externalId': '12345_external',
'ddName': 'order',
'fileName': 'file1.jpg',
'content': "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAA"
}])