Workflow: Document Type
A Document Type workflow is a special workflow type that defines the process for generating a document such as a PDF, Excel, or CSV. It can be used to generate various document types, such as invoices, purchase orders, and more.
When to Use a Document Type Workflow
- To generate PDFs or other file formats for business transactions
- To automate the creation of standardized documents (e.g., invoices, quotes, certificates)
- To ensure all relevant data fields are present in the final output
Outputs
A Workflow Document Type must provide the following outputs:
file
: Binary data of the generated document. (Required)fileName
: Name of the generated document file. (Required)fileDisposition
: Attachment disposition of the generated document file (attachment, inline, etc.). (Optional)- If no value is provided, it defaults to
"attachment"
.
- If no value is provided, it defaults to
Tags
A Workflow Document Type must have the following tags:
-
invoice
: Indicates that the document can be used to generate an invoice document. -
purchaseOrder
: Indicates that the document can be used to generate a purchase order document. -
quote
: Indicates that the document can be used to generate a quote document. -
parcel
: Indicates that the document can be used to generate a parcel document. -
warehouseReceipt
: Indicates that the document can be used to generate a warehouse receipt document. -
airShipment
: Indicates that the document can be used to generate an air shipment document. -
oceanShipment
: Indicates that the document can be used to generate an ocean shipment document. -
pdf
: Indicates that the document is a PDF. -
html
: Indicates that the document is an HTML document. -
csv
: Indicates that the document is a CSV document. -
xlsx
: Indicates that the document is an Excel document. -
docx
: Indicates that the document is a Word document. -
txt
: Indicates that the document is a text document. -
json
: Indicates that the document is a JSON document.
Example
workflow:
name: "Documents / Invoice"
workflowId: "2e28201d-704e-40b1-8568-7a87d198e255"
isActive: true
workflowType: "Document"
executionMode: "Sync" # Document workflows can only be executed in Sync mode
version: "1.0"
tags:
- "invoice"
- "pdf"
variables:
- name: "fileName"
value: "invoice.pdf"
- name: "organizationId"
value: 123 # Example usage, set or update as needed
inputs:
- name: "orderId"
type: "number"
props:
visible: false
mapping: "order.orderId"
outputs:
- name: "file"
mapping: "generateDocument.invoice.document" # Binary data of the generated document
- name: "fileName"
mapping: "filename" # Name of the generated document file
- name: "fileDisposition"
mapping: "attachment" # Defaults to "attachment" if not specified
triggers:
- type: "Manual" # Document workflows can only be triggered manually
displayName: "Generate Invoice PDF"
entityName: "Order"
activities:
- name: data
tasks:
- task: "Query/GraphQL"
name: "getOrder"
inputs:
query: |
query($orderId: Int!, $organizationId: Int!) {
order(orderId: $orderId, organizationId: $organizationId) {
...OrderFields
}
}
variables:
orderId: "{{ orderId }}"
organizationId: "{{ organizationId }}"
outputs:
- name: "order"
mapping: "order"
- name: "generateDocument"
tasks:
- task: "Document/Render"
name: "invoice"
inputs:
template:
engine: "handlebars"
recipe: "pdf"
content:
$raw: | # Raw template content to skip workflow template lookup
<html>
<head>
<title>Invoice</title>
</head>
<body>
<h1>Invoice</h1>
<p>Order Id: {{ order.orderId }}</p>
<p>Order Date: {{ order.orderDate }}</p>
<p>Order Total: {{ order.orderTotal }}</p>
</body>
</html>
data: "{{ data.getOrder.order }}"
outputs:
- name: "file"
mapping: "document" # Binary data of the generated document