You are here

Document Templates

Use the Generate Document task to generate a PDF or Microsoft Word document based on a Word document template (.docx). You can insert process variables in the MS Word template that will be replaced with actual values during document transformation.

A document template can be:

  • Tenant wide: Anyone can use this template in their processes. Useful for company templates.

  • Process model specific: This template is uploaded while modeling the process model, and is bound to the lifecycle of the process model.

When exporting an App model, process model document templates are included by default and are uploaded again on import. Tenant document templates are not exported, however matched by the document template name as names are unique for tenant document templates.

In the .docx template, you can insert process variables using the following syntax:


Since the above method does not perform null checks, an exception will be thrown at run-time if the variable is null. Therefore, use the following method to prevent such errors:


If this variable is null, a default value will be inserted instead. You can also provide a default value:

<<[variables.get("myVariable", "myDefaultValue")]>>

Note: Form field types such as Dropdown, Radio button, and Typeahead use myVariable_ID for ID and myVariable_LABEL for label value. The ID is the actual value used by service tasks and are inserted by default. To display the label value in the generated document, use myVariable_LABEL.

The document generation method uses the Aspose library in the back-end. For more information about the template syntax and options, see Aspose documentation.

When using the Generate Document task, make sure to use the correct syntax for your variables and expressions. Surround your variables with <<[..]>> characters. For example:




Some more examples:

  • If/else conditional blocks (see Aspose Documentation > Using Conditional Blocks):

    • Text type: <<if [textfield==day]>> AM, <<else>> PM \<</if>>

    • Amount type: <<if [annualsalary > $40000]>>, it is generous, <<else>> a standard starting salary \<</if>>

    • Checkbox: <<if [senstitiveflag=="true"]>>it is Confidential, <<else>> Not Confidential \<</if>>

  • Date type: <<[datefield]>>

    • Format date type: <<[datefield]>>:"yyyy.MM.dd">>

  • Number/amount: <<[amountfield]>>

  • String Boolean: <<[Genericcheckbox]>>

  • Radio button / Typehead / dropdown: Select <<[Options_LABEL]>> with an ID <<[Options_ID]>>

The audit log is also generated the same way. For example, the following snippet from the template shows advanced constructs:


It is also possible to have custom Spring bean that processes the process variables just before rendering the document, Processing document generation variables.

Sending feedback to the Alfresco documentation team

You don't appear to have JavaScript enabled in your browser. With JavaScript enabled, you can provide feedback to us using our simple form. Here are some instructions on how to enable JavaScript in your web browser.