Attachment Workflow Tasks
Attachment tasks are used to create, update, delete, and manage Attachments including thumbnail generation.
Create Attachment
Inputs:
attachmentType- Attachment type (required). Types: Picture, OtherDocumentfileName- File name (required)description- Description (optional)parentId- Parent id (optional). Order id, Job id, Contact id, etc.parentType- Parent type (optional). Types: Order, Job, Contact, AccountingTransaction.
task: "Attachment/Create@1"
name: createAttachment
inputs:
attachment:
attachmentType: "{{ attachmentType }}"
fileName: "{{ fileName }}"
description: "{{ description }}"
parentId: "{{ parentId }}"
parentType: "{{ parentType }}"
fileData: "{{ fileData }}" # base64 encoded file data or Stream object
outputs:
- name: attachment
mapping: "attachment"
Get Attachment
task: "Attachment/Get@1"
name: getAttachment
inputs:
attachmentId: "123"
outputs:
- name: attachment
mapping: "attachment"
Update Attachment
task: "Attachment/Update@1"
name: updateAttachment
inputs:
attachmentId: "123"
values:
attachmentType: "{{ attachmentType }}"
description: "{{ description }}"
fileName: "{{ fileName }}"
Delete Attachment
task: "Attachment/Delete@1"
name: deleteAttachment
inputs:
attachmentId: "123"
Thumbnail
task: "Attachment/Thumbnail@1"
name: thumbnail
inputs:
file: "{{ url }}"
options:
uploadLocation: "{{ parentType }}/{{ attachmentId }}/{{ fileName }}" # previews/{{organizationId}} will be added to the path
thumbnails:
- width: 100
height: 100
quality: 100
format: "png"
fileName: "{{ fileName }}-100x100"
- width: 200
height: 200
quality: 100
format: "png"
fileName: "{{ fileName }}-200x200"
outputs:
- name: thumbnails
mapping: "thumbnails"
Output:
{
"thumbnails": [
{
"fileName": "file-100x100.png",
"fileUri": "https://example.com/file-100x100.png"
},
{
"fileName": "file-200x200.png",
"fileUri": "https://example.com/file-200x200.png"
}
]
}
Regenerate Thumbnails
Regenerates missing preview and thumbnail images for attachments. Useful for fixing attachments that failed initial thumbnail generation or for bulk regeneration.
Inputs:
| Input | Type | Required | Description |
|---|---|---|---|
organizationId | number | Yes | Organization ID |
attachmentId | number | No | Specific attachment ID (regenerate single attachment) |
limit | number | No | Max attachments to process in bulk mode (default: 100) |
Outputs:
| Output | Type | Description |
|---|---|---|
processed | number | Number of attachments processed |
succeeded | number | Number of successful regenerations |
failed | number | Number of failed regenerations |
errors | array | List of error details |
Single Attachment Regeneration
task: "Attachment/RegenerateThumbnails@1"
name: regenerateSingle
inputs:
organizationId: "{{ number organizationId }}"
attachmentId: "{{ number attachmentId }}"
outputs:
- name: result
mapping: "result"
Bulk Regeneration
Regenerates thumbnails for all attachments in the organization (up to the specified limit). This is a forced regeneration that processes all attachments regardless of existing preview/thumbnail state.
task: "Attachment/RegenerateThumbnails@1"
name: regenerateAll
inputs:
organizationId: "{{ number organizationId }}"
limit: 500
outputs:
- name: result
mapping: "result"
Output Example:
{
"processed": 10,
"succeeded": 8,
"failed": 2,
"errors": [
{ "attachmentId": 123, "error": "File not found" },
{ "attachmentId": 456, "error": "Invalid image format" }
]
}
Example Attachment Workflow
workflow:
name: "Attachment / Create Attachment Example Workflow"
description: "Create Attachment Example Workflow"
version: "1.0"
executionMode: "Sync"
inputs:
- name: "organizationId"
type: "Organization"
displayName: "Organization id"
description: "Organization id"
multiple: false
required: true
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.organizationId"
- name: "attachmentType"
type: "AttachmentType"
displayName: "Attachment type"
description: "Attachment type"
multiple: false
required: true
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.attachmentType"
- name: "description"
type: "string"
displayName: "Description"
description: "Description"
multiple: false
required: false
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.description"
- name: "fileName"
type: "string"
displayName: "File name"
description: "File name"
multiple: false
required: true
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.fileName"
- name: "fileUri"
type: "string"
displayName: "File uri"
description: "File uri"
multiple: false
required: true
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.fileUri"
- name: "parentId"
type: "number"
displayName: "Parent id"
description: "Parent id"
multiple: false
required: false
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.parentId"
- name: "parentType"
type: "AttachmentParentType"
displayName: "Parent type"
description: "Parent type"
multiple: false
required: true
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.parentType"
- name: "previewUri"
type: "string"
displayName: "Preview uri"
description: "Preview uri"
multiple: false
required: false
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.previewUri"
- name: "thumbnailUri"
type: "string"
displayName: "Thumbnail uri"
description: "Thumbnail uri"
multiple: false
required: false
defaultValue: ""
additionalProperties:
visible: true
mapping: "attachment.thumbnailUri"
outputs:
- name: attachment
mapping: "createAttachmentActivity.createAttachment.attachment"
activities:
- name: "createAttachmentActivity"
description: "Create Attachment"
steps:
- task: "Attachment/Create@1"
name: createAttachment
inputs:
attachment:
organizationId: "{{ organizationId }}"
attachmentType: "{{ attachmentType }}"
description: "{{ description }}"
fileName: "{{ fileName }}"
fileUri: "{{ fileUri }}"
parentId: "{{ parentId }}"
parentType: "{{ parentType }}"
previewUri: "{{ previewUri }}"
thumbnailUri: "{{ thumbnailUri }}"
outputs:
- name: attachment
mapping: "attachment"
- name: "getAttachmentActivity"
description: "Get Attachment"
steps:
- task: "Attachment/Get@1"
name: getAttachment
inputs:
attachmentId: "{{ createAttachmentActivity.createAttachment.attachment.attachmentId }}"
outputs:
- name: attachmentFromGet
mapping: "attachment"
- name: "updateAttachmentActivity"
description: "Update Attachment"
steps:
- task: "Attachment/Update@1"
name: updateAttachment
inputs:
organizationId: "{{ getAttachmentActivity.getAttachment.attachment.organizationId }}"
attachmentId: "{{ getAttachmentActivity.getAttachment.attachment.attachmentId }}"
attachment:
attachmentType: "{{ attachmentType }}"
description: "{{ description }}"
fileName: "{{ fileName }}"
fileUri: "{{ fileUri }}"
parentId: "{{ parentId }}"
parentType: "{{ parentType }}"
previewUri: "{{ previewUri }}"
thumbnailUri: "{{ thumbnailUri }}"
- name: "deleteAttachmentActivity"
description: "Delete Attachment"
steps:
- task: "Attachment/Delete@1"
name: deleteAttachment
inputs:
organizationId: "{{ getAttachmentActivity.getAttachment.attachment.organizationId }}"
attachmentId: "{{ getAttachmentActivity.getAttachment.attachment.attachmentId }}"