Description
In this article, you will learn:
- how to create an array to be used in a workflow.
- two options for adding values to this array.
Instructions
Creating an array
Here’s how to define and declare arrays in Studio Pro:
1. Use the Assign value to variable activity.
2. Into the "Variable value" parameter, select "Calculate a value".
3. To create an empty array, enter the []
value as shown in the following screenshot:
Now, let us see two ways of adding values to an array.
Creating an array with values
When creating an array, you can add variable information into the brackets using this format: ["value1", "value2", "value3", "etc"]
. Here's an example:
Pushing values into an existing array
If you have already created the array, use the Execute JS code activity. Let us assume that you have an array called "fruit" with values "Apple" and "Mango", as follows:
Use the Execute JS code activity to run the command fruit.push()
and fill the parenthesis with the desired value. For example, fruit.push("Grape")
:
Now you just need to execute the workflow — and it's done! You have an extra value in the array: