Learn by product

Select the product you would like help with:

Martini Logo
Select the product you would like help with:
Knowledge Base


Dealing with Arrays in Gloop

Modified on: Fri, 5 Oct, 2018 at 11:12 AM

Mapping Arrays Using Set Expression

If you just want to populate or initialize your declared array with values manually, you can use Set Expression editor. The expression will vary depending

on what type of array you are mapping to. Below are some samples. Note: If you are trying to map a value from another array to your existing array,

skip this topic and check Mapping Arrays Using Iterate Step that comes after.

Array of Primitive Types or Strings

When mapping an array of primitive type or strings, you can initialize its values like so:

Array of Models

The expression for initializing or mapping to an array of Gloop Models is different when Set Expression is used.

Ninja Tip: Open the content assist by pressing control+space* on MacOS and type 'dsl' which will give you a Gloop Model DSL template you 

can use to assign or initialize values to an element of your array.

Initializing an Array of Gloop Model with Multiple Values

If you want to initialize your array of Gloop Models with multiple values, you can enter a new line, without and separator or delimiter like so.

Mapping Arrays Using Iterate Step

If you need to populate your array with values from another array, you can use Iterate Step and  Map Step to do the mapping for you. To do this,

in your Gloop Service Editor, open up content assist by pressing dot(.) key and type iterate over. A suggestion will appear and it's the one we want.

Once selected, the content assist will guide you through the setup like asking what's the input and output array. The input and output arrays

just basically where the values will be coming from, and where the values will be mapped respectively. For this example, we will be using words[]

as the input array and mappedWords[] as the output array 

The resulting step would be of the one below:

The next step would be mapping the values from words[] to mappedWords[]. We can do this by adding a new Map Step as a child step of the

Iterate Step you created earlier. You can do this by selecting the Iterate Step, opening the content assist by pressing dot(.) key, then by typing Map.

The service at this point should look like this:

Once you have this set up, double-click the Map Step to open the Mapper View.

You will notice that the words and mappedWords doesn't look like an array anymore, instead they are now what you think it is, just a string. This

is because arrays inside an Iterate Step are treated as single entries rather than array itself. We have two array of words as an input and output

and so we are given two single entry instance of those arrays. With this, we are now ready to process each values from the input array and add it

to our output array (which is represented by a green arrow that goes left to right. This means words is dragged-and-dropped over mappedWords)

You can also use the same approach for dynamically populating your Gloop Model array.

To Append or Not To Append

When configuring an iterate over step, you'll notice a property called Append that accepts values true or falseSetting the value to true will not

overwrite the existing values on the Output Array if any, while setting the value to false will do the opposite..

*Depending on your OS, shortcut will vary. If you are using a different OS, look for the equivalent key. Also depending on the context, you can also

use dot(.) key to open the content assist feature.

Did you find it helpful? Yes No

Can you please tell us how we can improve this article?