Skip to main content

Quote Document (Example)

This workflow is used to generate a document for a pickup order. The document is generated in PDF format and contains the following information:

Example quote document workflow

Explanation:

  • The workflow is triggered by an order ID.
  • The workflow retrieves the order details from the GraphQL API.
  • The workflow generates a PDF document using the order details using jsrender template engine.
  • The workflow outputs the PDF document, the file name, and the file disposition.
workflow:
name: "Document / Quote"
description: "Document / Quote"
workflowId: "6421a125-aa74-43fd-9da0-864da2c896f1"
isActive: true
workflowType: "Document"
executionMode: "Sync" # Document workflows can only be executed in Sync mode
version: "1.0"
enableAudit: false

inputs:
- name: "orderId"
type: "number"

variables:
- name: "attachment"
value: "attachment"

outputs:
- name: "file"
mapping: "generateDocument.render.document" # Binary data of the generated document
- name: "fileName"
mapping: "Quote_{{data.getOrder.order.orderNumber}}.pdf" # Name of the generated document file
- name: "fileDisposition" #
mapping: "attachment" # Attachment disposition of the generated document file (attachment, inline, etc.)

activities:
- name: "data"
steps:
- task: "Query/GraphQL"
name: "getOrder"
outputs:
- name: "order"
mapping: "order"
inputs:
variables:
organizationId: "{{ organizationId }}"
orderId: "{{ orderId }}"
query: |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quote</title>
<style>
body {
font-family: Arial, sans-serif;
font-size: 12px;
line-height: 1.3;
margin: 0;
padding: 10px;
}
.header {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
}
.company-info {
flex: 1;
}
.company-info h1 {
font-size: 18px;
margin: 0 0 5px 0;
}
.company-info p {
margin: 0;
font-size: 11px;
}
.order-info {
width: 250px;
}
.order-info h2 {
font-size: 16px;
margin: 0 0 0px 0;
text-align: center;
background-color: #000;
color: #fff;
}
.order-info table {
width: 100%;
margin: -6px;
border-collapse: collapse;
}
.order-info td {
padding: 3px;
border: 1px solid #000;
}
.section {
margin-bottom: 5px;
}
.info-box {
border: 1px solid #000;
padding: 5px;
}
.info-box-title {
font-weight: bold;
margin-bottom: 5px;
padding: 3px;
background-color: #000;
color: #fff;
}
.info-box .info-box-title {
margin-top: -5px;
margin-left: -5px;
margin-right: -5px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #000;
padding: 4px;
text-align: left;
}
th {
background-color: #000;
color: #fff;
font-weight: bold;
}
.notes, .charges {
border: 1px solid #000;
padding: 5px;
}
.signature {
margin-top: 20px;
}
.totals td:first-child {
text-align: right;
font-weight: bold;
}
.numeric {
text-align: right;
}
</style>
</head>
<body>
<div class="header">
<div class="company-info">
<h1>{{:organization.companyName}}</h1>
<p>{{if organization.addressLine}}{{:organization.addressLine}}{{/if}}</p>
<p>{{if organization.cityName}}{{:organization.cityName}}{{/if}}{{if organization.stateCode}}, {{:organization.stateCode}}{{/if}} {{if organization.postalCode}}{{:organization.postalCode}}{{/if}}</p>
<p>{{if shipper && shipper.contactAddress && shipper.contactAddress.country && shipper.contactAddress.country.name}}{{:shipper.contactAddress.country.name}}{{/if}}</p>
<p>Tel: {{if shipper && shipper.contact && shipper.contact.phoneNumber}}{{:shipper.contact.phoneNumber}}{{/if}}{{if organization.faxNumber}}, Fax: {{:organization.faxNumber}}{{/if}}</p>
</div>
<div class="order-info info-box">
<div class="info-box-title"><h2>Pickup Order</h2></div>
<table>
<tr><td><strong>Order Number</strong></td><td>{{if orderNumber}}{{:orderNumber}}{{/if}}</td></tr>
<tr><td><strong>Tracking Number</strong></td><td>{{if trackingNumber}}{{:trackingNumber}}{{/if}}</td></tr>
<tr><td><strong>Mode of Transportation</strong></td><td>{{if customValues && customValues.modeOfTransportationName}}{{:customValues.modeOfTransportationName}}{{/if}}</td></tr>
<tr><td><strong>Delivery Method</strong></td><td>{{if customValues && customValues.selectedDeliveryMethodId}}{{:customValues.selectedDeliveryMethodId}}{{/if}}</td></tr>
<tr><td><strong>Payment Method</strong></td><td>{{if customValues && customValues.contactPaymentMethodDescription}}{{:customValues.contactPaymentMethodDescription}}{{/if}}</td></tr>
</table>
</div>
</div>

<div class="section">
<div class="info-box" style="width: 48%; float: left;">
<div class="info-box-title">Bill To Information</div>
<p><strong>{{if billToContact && billToContact.name}}{{:billToContact.name}}{{/if}}</strong></p>
<p>{{if billToContact && billToContact.billingAddress && billToContact.billingAddress.addressLine}}{{:billToContact.billingAddress.addressLine}}{{/if}}</p>
{{if billToContact && billToContact.billingAddress && billToContact.billingAddress.addressLine2}}<p>{{:billToContact.billingAddress.addressLine2}}</p>{{/if}}
<p>{{if billToContact && billToContact.billingAddress && billToContact.billingAddress.cityName}}{{:billToContact.billingAddress.cityName}}{{/if}}{{if billToContact && billToContact.billingAddress && billToContact.billingAddress.state && billToContact.billingAddress.state.name}}, {{:billToContact.billingAddress.state.name}}{{/if}} {{if billToContact && billToContact.billingAddress && billToContact.billingAddress.postalCode}}{{:billToContact.billingAddress.postalCode}}{{/if}}</p>
<p>{{if billToContact && billToContact.billingAddress && billToContact.billingAddress.country && billToContact.billingAddress.country.name}}{{:billToContact.billingAddress.country.name}}{{/if}}</p>
<p>Tel: {{if billToContact && billToContact.phoneNumber}}{{:billToContact.phoneNumber}}{{/if}}</p>
</div>
<div class="info-box" style="width: 48%; float: right;">
<div class="info-box-title">Shipping Information</div>
<p><strong>{{if billToContact && billToContact.name}}{{:billToContact.name}}{{/if}}</strong></p>
<p>{{if billToContact && billToContact.shipping && billToContact.shipping.addressLine}}{{:billToContact.shipping.addressLine}}{{/if}}</p>
{{if billToContact && billToContact.shipping && billToContact.shipping.addressLine2}}<p>{{:billToContact.shipping.addressLine2}}</p>{{/if}}
<p>{{if billToContact && billToContact.shipping && billToContact.shipping.cityName}}{{:billToContact.shipping.cityName}}{{/if}}{{if billToContact && billToContact.shipping && billToContact.shipping.state && billToContact.shipping.state.name}}, {{:billToContact.shipping.state.name}}{{/if}} {{if billToContact && billToContact.shipping && billToContact.shipping.postalCode}}{{:billToContact.shipping.postalCode}}{{/if}}</p>
<p>{{if billToContact && billToContact.shipping && billToContact.shipping.country && billToContact.shipping.country.name}}{{:billToContact.shipping.country.name}}{{/if}}</p>
<p>Tel: {{if billToContact && billToContact.phoneNumber}}{{:billToContact.phoneNumber}}{{/if}}</p>
</div>
<div style="clear: both;"></div>
</div>

<div class="section">
<table>
<tr>
<td>Shipper</td>
<td>{{if shipper && shipper.contact && shipper.contact.name}}{{:shipper.contact.name}}{{/if}}</td>
<td>Consignee</td>
<td>{{if consignee && consignee.contact && consignee.contact.name}}{{:consignee.contact.name}}{{/if}}</td>
</tr>
</table>
</div>

<div class="section">
<div class="info-box-title">Carrier Information</div>
<table>
<tr>
<td>Carrier Name</td>
<td>{{if carrier && carrier.contact && carrier.contact.name}}{{:carrier.contact.name}}{{/if}}</td>
<td>Carrier Phone</td>
<td>{{if carrier && carrier.contact && carrier.contact.phoneNumber}}{{:carrier.contact.phoneNumber}}{{/if}}</td>
</tr>
<tr>
<td>Attachment ID</td>
<td>{{if carrier && carrier.contact && carrier.contact.customValues && carrier.contact.customValues.attachmentId}}{{:carrier.contact.customValues.attachmentId}}{{/if}}</td>
<td>Is Consolidated</td>
<td>{{if customValues && customValues.isConsolidated}}{{:customValues.isConsolidated}}{{/if}}</td>
</tr>
</table>
</div>

<div class="section" style="display: flex; justify-content: space-between;">
<div class="info-box" style="width: 100%;">
<div class="info-box-title">Applicable Charges</div>
<table>
<tr>
<th>Description</th>
<th>Quantity</th>
<th>Price</th>
<th>Total Amount</th>
<th>Currency</th>
<th>Note</th>
</tr>
{{for charges}}
<tr>
<td>{{if description}}{{:description}}{{/if}}</td>
<td class="numeric">{{if quantity}}{{:quantity}}{{/if}}</td>
<td class="numeric">{{if price}}{{:price}}{{/if}}</td>
<td class="numeric">{{if totalAmount}}{{:totalAmount}}{{/if}}</td>
<td>{{if currency && currency.currencyCode}}{{:currency.currencyCode}}{{/if}}</td>
<td>{{if note}}{{:note}}{{/if}}</td>
</tr>
{{/for}}
</table>
</div>
</div>

<div class="section">
<div class="info-box-title">Order Commodities</div>
<table>
<tr>
<th>Pieces</th>
<th>Description</th>
<th>Weight</th>
<th>Dimensions</th>
<th>Volume</th>
<th>Value</th>
</tr>
{{for orderCommodities}}
<tr>
<td>{{if commodity && commodity.pieces}}{{:commodity.pieces}}{{/if}}</td>
<td>{{if commodity && commodity.description}}{{:commodity.description}}{{/if}}</td>
<td>{{if commodity && commodity.weight}}{{:commodity.weight}}{{/if}} {{if commodity && commodity.weightUnit}}{{:commodity.weightUnit}}{{/if}}</td>
<td>{{if commodity && commodity.width}}{{:commodity.width}}{{/if}}x{{if commodity && commodity.height}}{{:commodity.height}}{{/if}}x{{if commodity && commodity.length}}{{:commodity.length}}{{/if}} {{if commodity && commodity.dimensionsUnit}}{{:commodity.dimensionsUnit}}{{/if}}</td>
<td>{{if commodity && commodity.volumeTotal}}{{:commodity.volumeTotal}}{{/if}} {{if commodity && commodity.volumeUnit}}{{:commodity.volumeUnit}}{{/if}}</td>
<td>{{if commodity && commodity.unitaryValueTotal}}{{:commodity.unitaryValueTotal}}{{/if}}</td>
</tr>
{{for commodity.containerCommodities}}
<tr>
<td>{{if pieces}}{{:pieces}}{{/if}}</td>
<td>{{if description}}{{:description}}{{/if}} {{if commodityType && commodityType.description}}({{:commodityType.description}}){{/if}}</td>
<td>{{if weight}}{{:weight}}{{/if}} {{if weightUnit}}{{:weightUnit}}{{/if}}</td>
<td>{{if width}}{{:width}}{{/if}}x{{if height}}{{:height}}{{/if}}x{{if length}}{{:length}}{{/if}} {{if dimensionsUnit}}{{:dimensionsUnit}}{{/if}}</td>
<td>{{if volumeTotal}}{{:volumeTotal}}{{/if}} {{if volumeUnit}}{{:volumeUnit}}{{/if}}</td>
<td>{{if unitaryValueTotal}}{{:unitaryValueTotal}}{{/if}}</td>
</tr>
{{/for}}
{{/for}}
</table>
</div>

<div class="section">
<div class="info-box">
<div class="info-box-title">Additional Information</div>
<p><strong>Estimated Shipping Cost:</strong> {{if customValues && customValues.estimatedShippingCost}}{{:customValues.estimatedShippingCost}}{{/if}}</p>
<p><strong>Mode of Transportation:</strong> {{if customValues && customValues.modeOfTransportationName}}{{:customValues.modeOfTransportationName}}{{/if}} {{if customValues && customValues.modeOfTransportationId}}(ID: {{:customValues.modeOfTransportationId}}){{/if}}</p>
<p><strong>Selected Delivery Method ID:</strong> {{if customValues && customValues.selectedDeliveryMethodId}}{{:customValues.selectedDeliveryMethodId}}{{/if}}</p>
<p><strong>Payment Method:</strong> {{if customValues && customValues.contactPaymentMethodDescription}}{{:customValues.contactPaymentMethodDescription}}{{/if}}</p>
</div>
</div>

<div class="signature">
<p>Signature: _______________________________</p>
</div>
</body>
</html>