How to create array variable in studio
You can calculate a value like this:
Use var = []; or var = new Array();
Hi @Rudhresh, we would like to find out if the solution provided above worked. If it did, please mark the answer above as the solution.
Hi @Rudhresh, here is a step by step guide on how you can create a Array in studio
-
First you need to use the Assign value to variable activity.
-
Into the “Variable value” parameter, select “Calculate a value.”
-
To create an empty array, enter the value as shown in the following screenshot:
Here is how you can add values to the 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:
I hope this helps @Rudhresh