How to create an Array

How to create array variable in studio

1 Like

You can calculate a value like this:
Use var = []; or var = new Array();

array

1 Like

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

  1. First you need to 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:

Captura_de_Pantalla_2023-01-17_a_la_s__08.45.46.png

Captura_de_Pantalla_2023-01-17_a_la_s__08.45.58.png

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:

image-20221229-140526.png

image-20221229-140827.png

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:

mceclip0.png

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"):

mceclip1.png

Now you just need to execute the workflow — and it’s done! You have an extra value in the array:

mceclip3.png

I hope this helps @Rudhresh