File: Custom Document

Knowledge Center > Workflow > Workflow Tasks > File: Custom Document

File: Custom Document

Table of contents

The custom document task generates an invoice based on the HTML template that you provide in the task. This task is similar to the Custom Invoice task. The only difference is that the custom document task does not attach the generated invoice to an object record.

You can customize your invoice template using HTML tags, CSS, images, JavaScript and Liquid expressions.

Configuration

In upstream tasks, you need to retrieve the data fields you want to include in the template.

Use JavaScript or Liquid to add logic or data to the template. You can also reference external JavaScript libraries.

workflow_task_custom_document.png

Liquid expressions start with '{%' and end with '%}'.

This code block uses Liquid to pass data to a JavaScript constant object.

const usages =  {% if Data.Usage %}
    {{- Data.Usage | to_json -}};
{%- else -%}
    [{"UOM":"kWh","Quantity":1229.9,"StartDateTime":"2018-08-01T00:00:00.000-07:00"},
    {"UOM":"kWh","Quantity":1265.56,"StartDateTime":"2019-07-01T00:00:00.000-07:00"}];
{%- endif -%}

The following code block adds data to a div element. Depending on the value of a data field, it adds different strings to the div element.

 <div style='font-size: 10px'>
{%- if Data.Invoice[0].InvoiceNumber and Data.Invoice[0].InvoiceNumber != "" -%} 
{{- Data.Invoice[0].InvoiceNumber }}
{%- else -%}0001{%- endif -%}
</div>

For a complete use case and template code examples, see the "Custom Invoice" workflow template under the Invoicing category. This template is explained in Customize invoice templates using HTML.

Output

If the task runs successfully, you can view the output in the Tasks tab. Click the menu icon on the left of the task and hover on Files. You can select either the HTML or PDF version of the invoice. The PDF file is generated based on the HTML file. If you want to do one-time changes, you can modify the HTML file and then generate a PDF file based on the HTML file. 

workflow_custom_document_output.png

 

Last modified

Tags

Classifications

(not set)