You can define two kinds of variables in your templates:
- A normal variable, which is defined and used only within the template.
- A workflow variable that can be used, for example, to send user-defined variable information from the workflow to a template, or vice versa.
This section covers the workflow variables as used inside a template. The workflow variable element can be inserted with this icon:
The
only place where you can define a workflow variable element in the
designer is prior to the page element(s), so you should click the
template element to add a workflow variable
The workflow variables can be created and updated only in the workflow with the two workflow components:
- Set workflow variable
- Set multiple workflow variables
Inside the template, you can refer to these workflow variables as input, but you cannot assign a new value to a workflow variable. If you want variables that you can create and update in the template, then you should use the variable element.
If you want to refer to a workflow element in a template, then you can simply type the name of the workflow variable with a preceding $-sign, e.g., in XPath expressions.
Important: A workflow variable is always defined as a string, so if you use such a variable as index in XPath, then you need to cast this as a number e.g. like so:
/Root/Document[number($Index)]/@Company.
Also, if you want to create a counter to keep track of the current number of repeats, then you also need to use the number function when you increment the value e.g., like so:
It is, however a good idea to define the workflow variables that you want to use in the template because of this:
- It is clear to see, which workflow variables, that the template is using as input, so you should consider to verify, that these variables are setup in the workflows, that are using the template.
- You can assign a preview/placeholder value in the designer and in this way directly in the designer see, how the template reacts to varies values of the workflow variable.
The only place where you can define a workflow variable element in the designer is prior to the page element(s), so you should click the template element to add a workflow variable:
Now you can add a new workflow variable with this icon:
In the workflow variable element you can let the template know, that a specific workflow variable is expected, and you can also assign a value to be used, when you are designing:
In the example above a variable, Copies is set to the value '2'. This can be used by the workflow to request a variable number of copies of the document, and the designer can use the repeat element to produce the same number of repetitions when printing the merged result.
So as mentioned above the value '2' set above only has an effect, when you are designing and previewing without a workflow. In production the value is expected to be set in the workflow by either set workflow variable or set multiple workflow variables.
You can use workflow variables with the workflow input type, From input form menu. In order to do that you need to setup the editable section of the workflow variable:
The fields are:
Unique Id
This must be a unique name for the workflow variable. A recommendation is to simply state the name of the workflow variable.
Form Label
The header/description of the workflow variable.
Default value
The default value for the workflow variable. This value will be shown when the From input form menu is run.
Free text/Selectable text
Here you can decide that the user should either enter a free text or select the value via a drop down list, which is setup via a translation file like below:
This will only list the keys that starts with Ba in the referenced translation file.
With the values specified above this entry screen will be shown for this template:
With the workflow variable element you can also refer to both tenant variables and global variables. You can see these variables if you click the magnifying glass: