System and Workflow Variables
System and Workflow Variables are used to store temporary data that is available throughout the Workflow, usually for the purposes of displaying information to an agent, collating data, or acting as a flag to control the path through a Workflow. All System and Workflow Variables are prefixed by var_, and if they are used in code then they are wrapped in square brackets in the same manner as Fields.
Variables come in two varieties: System, and Workflow.
-
System Variables are built in to Scripting, and are either populated automatically on Workflow pop, or are dependent on a specific control/feature being used,
-
Workflow Variables are user-defined, and can be added or removed at will to support the Workflow process.
Data stored in Variables is not saved after the Workflow closes, so any data that is held solely in a Variable must be written to a control on the Workflow page (commonly a
Hidden field) if you wish to store its value.
In this example, a variable is used to display an appropriate greeting in a Text Label at the start of a Workflow:
System Variables
System (built-in) variables provide access to a wide range of system information useful for Workflow building or reporting. Probably the most commonly used example of a system variable is [var_csAgentName], which is often used in labels on the opening page of a Workflow:
When the Workflow is running, the first and last name of the agent running the Workflow will display in place of [var_csAgentName].
Workflow Variables
Unlike System Variables which exist automatically for all Workflows, Workflow Variables are created by a user and exist independently in different Workflow Versions.
Workflow Variables can either be created by clicking the
Variables button at the top-right corner of the Workflow Designer window:
Once the button has been clicked, the Variables modal is then opened:
Workflow Variables can then be imported or created by clicking the appropriate buttons at the top of the Variable list.
Importing Workflow Variables
Upon clicking the Import button, an instance of the
Import Wizard is launched, with the final step being to define the datagroups for the variables' Name, Default Value, and Description.
Creating Workflow Variables
Upon clicking the Add button, a modal will pop up where you can enter the variable name. Note that all variables are automatically prefixed with var_ so there is no need to type this part again. Variables can only contain alphanumeric characters or underscores.
When happy with the Variable's name, click the Add button. The created Variable will be added to the Variable list and selected, and additional information such as a Default Value or Description can then be added if desired:
Comparison of Variables and Fields
Systems and Workflow Variables share some similarities, but also have some fundamental differences.
Variables
|
Fields
|
Accessible on any page in the Workflow.
|
Only accessible by JavaScript code on pages that the Field is actually present.
|
Can never be directly manipulated by an agent, only ever through code.
|
Many Fields can be directly viewed or set by an agent.
|
Data is lost as soon as the Workflow run is completed.
|
Data is saved to the Scripting database.
|
Have their name wrapped in square brackets whenever referenced in code.
|
Can have their value displayed in Text Labels.
|