Skip to content

Surveyjs processvariables

Using process variables

We have already seen in an example External Survey URI how a parameter reference is evaluated at runtime. In addition to the input and output parameters, process variables can also be used between process steps and in the survey forms. With these variables we can control the flow of the process, for example assigning the activity to the active agent's manager or repeating a step a certain number of times etc. A list of the process variables and how they can be used can be found under Documentation in the SurveyJS Creator, see the next image. They are variables related to agents, instances, nodes and execution that are internally necessary to the process during execution. For the correct functionality, the syntax of the process variables (e.g. ${} -> the agent's name or ${} -> node name) must be strictly followed when entering into the survey.

Documentation in the SurveyJs Creator

Agent variables

Due to a change in date and time formatting, the former ${Agent.dateFormat} and ${Agent.timeFormat} process variables are no longer needed and are removed from the process variables. Locale-specific formatting is now done in the browser using the browser's language. Since the date and time are now always in ISO format, the uniqueness of this information is guaranteed, regardless of the time zone in which the individual process steps are carried out. However, compatibility with older versions can no longer be supported because the two variables ${Agent.dateFormat} and ${Agent.timeFormat} are no longer used. The supported process variables are as follows:

Instance variables

Node variables

Execution variables

Example: Changing title

In the next example, the name of the process step is used as the title for the form. We achieve this via an HTML element that uses the ${} process variable.


As a result, you can then see the node name as the title of the survey in Test Client at runtime. Through this process variable we can display the survey title in each process step according to the node name.


Calculated Values

Processes often go through steps in which information is recorded, checked and supplemented. As in the previous example, we can pass this information to the elements of survey using variables, so that at runtime a survey looks different at each step, although it is always the same.

In order to make the functionality of the survey elements dependent on the process step, we need our process variables such as ${}. Unfortunately, we cannot use our process variables directly in the question logic, where you determine the behavior of the survey based on several conditions. However SurveyJs offers calculated values ​​in which we can integrate our process variable. These calculated values must be defined globally in the Survey / Logic under Calculated Values. Since the Calculated Values apply to the entire survey, select the survey in the top right corner of the Creator and enter the name and the corresponding expression. We enter the process variables exactly as they are specified, just without the dollar sign and curly brackets, eg, etc. It doesn't matter which expression you assign to this variable, since the current value of the process variable is automatically assigned at runtime. For an example with expressions in SurveyJs see the chapter Example Expression(read-only) question.

Calculated Values

After that we can associate a normal survey variable with our process variable, for example by creating an expression with the process variable. In the following the variable var1 has the value true if has the value '2'.

This globally defined variable can be used to control the logic of questions. That means we can make the question visible, editable or required, if the entered expression evaluates to true. In the following the question in panel1 is editable and required if the var1 results in true i.e. if the is '2'.

Form master

As described in Calculated Values, we call this type of survey a form master, because it contains all input fields and information for the entire process but adapts to the respective step in the course of the process. This form master, created in one process step, can be inserted into other process steps via copy/paste form context menu. In this way, all forms get the same appearance when modeling in the Process Template Editor and we can make changes in one central place. A form master can be created by showing or hiding multiple survey elements. For a small example using process variables in a form master, see the tutorial Hide/Show parts of the form.