Attachment Workflow Tasks
Attachment tasks are used to create, update, and delete Attachments.
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"
}
]
}
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 }}"