It is possible to define one or more variables in the InterformNG2 designer. The advantage is, that you can use variables e.g. to add up all the detail lines of a page and output the page total in the footer.
You can also use variables in normal XPath functions.
Another kind of variable is the workflow variable, which can be used for sending variables/information from the workflow to the template.
You can create or update a variable in the designer if you first click the plus icon (+) in the top and then the (x) icon as marked below:
After adding a variable element you will see this:
The parameters are:
Name
Here you should state the name of the variable. The variable name should be written as a plain text (not an Xpath expression) and the variable name is written without an initial dollar sign. The variables in InterformNG2 are case sensitive. A hyphen inside the variable name is allowed (from version 4.0.2).
Please note, that the name of a variable is not allowed to start with a number, it cannot contain a dollar sign and the variable names are case sensitive.
Expression
Here you should state an Xpath expression which returns the value, that you want to assign to the variable. Since this is an Xpath expression you will need to single (or double) quotes around a fixed text if you want to use that. You refer to variables with a preceding $-sign.
This element will assign the text, Hello world to the variable, MyVar:
In a repeat loop you can also use a variable to keep track of the iterations by adding 1 to the variable inside the repeat like below:
You can use this to output the numbers 1 to 10 in this small template:
Here the Counter variable is first set to the initial value of 1, then a repeat of 10 is run and inside the repeat the current value of the variable is output via a text element (referrring to the Counter variable) an then the value of the Counter is increased.
Description
This parameter is an optional description of the element. It does not influence the functionality.
This video introduce the use of variables in the designer: