Removing Attachments Lazily (V1) (persistent.removeAttachmentsLazyV1)
You can use persistent.removeAttachmentsLazyV1 to remove one or more specific attachments from a document using an older, V1 parameter format. This operation is staged and executed after the script finishes running. It internally maps the V1 parameters to the format used by persistent.removeAttachmentsLazy.
Syntax
persistent.removeAttachmentsLazyV1({ddName});
Parameters
The removeAttachmentsLazyV1 function takes a single parameter, which must be an array of objects. Each object in the array specifies an attachment to remove using the V1 format and must have the following properties:
Parameter | Type | Required | Description |
---|---|---|---|
ddName | String | Yes | The document definition name of the target document. |
_id | String | Yes (if externalId is not provided) |
The unique identifier (ID) of the target document. |
externalId | String | Yes (if _id is not provided) |
An external identifier for the target document. |
fieldName | String | Yes | The name of the field in the document containing the attachment(s). (This is mapped to valuePath internally). |
lineName | String | No | If the field is in a line, the name of the line. |
lineId | String | No (if lineName has no value, or if lineExternalId is provided) |
If lineName is provided, either lineId or lineExternalId is required. The ID of the target line. |
lineExternalId | String | No (if lineName has no value, or if lineId is provided) |
If lineName is provided, either lineId or lineExternalId is required. The external ID of the target line. |
fileName | String | Yes (if fileId is not provided) |
The name of the specific file to remove from the field specified by fieldName (and line if applicable). |
fileId | String | Yes (if fileName is not provided) |
The ID of the specific file to remove from the field specified by fieldName (and line if applicable). |
Return value
This function performs an action and does not return a value.
Examples
To give an better idea of how to use the removeAttachmentsLazyV1
function there will follow some examples below.
Example remove attachment with _id
The following example shows how to remove a specific attachment by its name from a document identified by its _id
in the 'invoices' document definition using the V1 format:
persistent.removeAttachmentsLazyV1([
{
ddName: 'invoices',
_id: 'invoice_789',
fieldName: 'invoiceFiles',
fileName: 'receipt.pdf'
}
]);
Example remove attachment with externalId
This example shows how to remove an attachment by its ID from a document identified by its externalId
in the 'reports' document definition, specifying line information using the V1 format:
persistent.removeAttachmentsLazyV1([
{
ddName: 'reports',
externalId: 'REPORT-XYZ',
fieldName: 'generatedFiles',
lineName: 'fileLine',
lineId: 'line_abc',
fileId: 'file_xyz'
}
]);