Workflow variable element

Workflow variable element

You can define two kinds of variables in your templates:

 

1.A normal variable, which is defined and used only within the template.

2.A workflow variable, which can be used for e.g. for sending user defined variable information from the workflow to a template.

 

This section covers the workflow variables.

 

The workflow variables can be created and updated only in the workflow with the two workflow components:

1.Set workflow variable

2.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 preceded $-sign e.g. in XPath expressions.

 

Important: Please note, that 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 need also to use the number function, when you increment the value e.g. like so:

NG2WorkflowVariableUpdateNumeric0001

 

 

It is however a good idea to define the workflow variables, that you want to use in the template because of this:

 

1.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.

2.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:

 

NG2WorkflowVariable0002

 

Now you can add a new workflow variable with this icon:

 

NG2WorkflowVariable0003

 

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:

 

NG2WorkflowVariable0004

 

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.

    • Related Articles

    • Variable element

      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 ...
    • Payload to workflow variable

      The advanced, utilities workflow component, Payload to variable copies the current payload into a variable. This can e.g. be used, if you want to insert the payload into an output file via a variable in a transformation. The payload to workflow ...
    • Set one workflow variable

      The advanced set meta data workflow component, Set one workflow variable, sets/defines a workflow variable. This can be used later in the workflow and also in a template in the designer. The variable can be referenced in XPath expressions with a ...
    • Resource to workflow variable

      With the workflow component, Resource to workflow variable (which is a shortcut component of the other category), you can read a resource from the library and store it in a workflow variable. A related component is: From file to workflow variable. ...
    • From file to workflow variable

      With the advanced utilities workflow component, From file to workflow variable you can extract the contents of a file in the file system and put that into the contents of a variable. A related component is: Resource to workflow variable. This can ...