Description
This activity lets you create and modify variables. They store the set value and can be used in other activities.
General usage of this activity:
- Set the name and value. For example, we have a variable named login_message and its value is some text like You have successfully logged in.
- Use this variable in other activities. For example, use it with ‘Save the previous step result’ in different activities.
Parameters
Let us review its parameters.
Variable name and value
Variable name is pretty self-explanatory. You can name variables as you see fit, but there are some restrictions and things to remember:
- The first symbol in the name must be a Latin character or underscore (_).
- The rest of the name can include any Latin letter, digit, or underscore.
- It is not possible to use JavaScript reserved words.
- Avoid using the $ symbol at the beginning and at the end of the name. Such names are reserved for ElectroNeek platform internal variables.
- Variable names are case-sensitive.
- All the variables declared in this block are global. This means that a variable can be used in any other .neek files.
In this example message is the name of the variable.
There is also a dropdown list that lets you choose the variable that is handled by the selected block.
Dropdown list containing other created variables
For example, we have these two variables: message and message2.
Two variables containing some text in the workflow
Currently, the lower block (containing message) is selected, and this is what we see. These parameters are set for the message variable.
Parameters of the message variable
What if we change the Variable name from message to message2 in this list? This is what will happen.
Redefinition of variable value
This output message shows that the new value was used
Basically, we have redefined the message2 variable. It can be seen in the output if we try to display the result in the console using the ‘Console log’ activity. This could come in handy in some situations.
Now let us move to the Variable value parameter. Similar to many other activities, it offers a few options:
Set a value lets you input the value manually. In this case, the type is automatically switched between Text and Number based on the input. Examples: Some text, 122.
Calculate a value lets you use JS to define a specific value. Example: some_variable * 2, someArray.length.
Save the previous step result lets you set the variable value using the result or output of the previous activity block.
Is Global
If you check the “Is Global” box, the variable created in this .neek file can be accessed from other files in the same project. In other words, the scope of the variable is global. Otherwise — if the checkbox is not selected —, the assigned variable is only available for the current .neek file, which means the scope of the variable is local.
Note that when you click on "Is Global", the "Output Data" option appears. Activate this parameter if you want to include the value of this variable in the output data of this workflow, so you can send it to SaaS Orchestrator and use it in another applications.
Click "Check selected variables" to see the Output tab. Learn more about this process in this article.