Skip to content






Service manager

API Explorer

Gloop map step icon

Map steps

The Gloop map step is used to set variable values and to declare new variables. There are two ways to set a variable in a map step:

  • A map line
  • A set expression

When a map step is chosen in the Gloop service editor, the Mapper view in Coder will show all of the available input and output variables. This is where you declare and map variable values and add set expressions.

Map lines

To map a variable, or in other words, assign the value of a variable to the value of another, simply drag and drop a variable to another as shown below:

Mapping a variable

Mapping a variable

The line in the GIF above is the same as the following code:

person.lastName = lastName

To delete a line, first click on the line to highlight it, then press or right click on the line and select the Delete menu item.

Removing variable mapping

Removing variable mapping

Set expressions

If the value of a variable is to be hardcoded, or requires some more advanced logic in order to set its value (such as performing lookups, or some sort of transformation, etc.), you can use a set expression instead of a map line.

When adding a set expression, you have the option whether to have Gloop evaluate it or not. When Gloop doesn't evaluate the set expression, then the expression itself is used as the value of the variable. When Evaluate is checked, then Gloop assumes the set expression is a Groovy snippet, which gets compiled and executed at runtime. The output of the Groovy snippet is used as the value of the variable.

Set step guidelines

Since evaluated set expressions are written in Groovy, you can (in theory) write dozens of lines of code in a set expression; however it's bad practice to do so. Instead, you should use a Gloovy step or write a reuseable Groovy class.

To add a set expression to a variable, right click on a variable in the output half of the Mapper view and double click on it, or press .

The Set Expression dialog has the available Gloop properties in a tree on the right hand side. If you double click on a variable in the tree while editing your expression, the Groovy code for accessing the variable is inserted into the set expression at the location of the cursor. Focus is kept on the script editor even when double clicking so the code can continue to be edited without having to manually put focus back on the editor.

Mapping to a set expression

Mapping to a set expression

Set step expressions like a ninja

As an alternative, you can also press on a map step, or right click it then select Edit Set Expression from the appearing context menu. Upon doing so, Coder will ask you to choose which variable you would like to set.

The set expression in the GIF above is the same as the following code:

person.dialog = "Hello, I'm ${firstName.toUpperCase()}"

To delete a set expression, right click on the variable and choose Delete Set Expression, or highlight the variable, and press .

Deleting a set expression

Deleting a set expression

Accessing the entire Gloop variable context

Set steps also have variable called $context included, which is actually a Gloop model that contains all of the variables that you see in the Mapper!

Map line and set expression priority

You may have noticed in the screenshots above that the Set Expression dialog has a Priority field. This field is used to determine the order in which the map lines and set expressions are executed. This allows you to map the same fields more than once in the same step. Take the following map step for example:

An example where the `Priority` field will matter

An example where the `Priority` field will matter

If all the lines in this example had the same priority, then there will be no guarantee on the order in which the lines were executed. Thankfully with the priority feature you can safely determine the order.

Map steps execute map lines and set expressions which have the lowest priority number first. This means that if the lines were configured like so:

Input Output Priority
a b 0
b c 1
c d 2
d a 3

Then it would be the same as the following Java code:

b = a;
c = b:
d = c;
a = d;

Priorities for map lines can be configured by clicking on the line itself (in the Mapper area in the middle) until it is highlighted, then changing the value of the Priority field in the Properties view.

Map line `Priority` change

Map line `Priority` change

Errors in set expressions

If your set expression throws an exception (regardless whether it was from a syntax error or not), Gloop will produce a standard Gloop stacktrace, but with an extra suffix telling you the line number where the error occurred in your set expression, and which set expression it was. For example, given the error below, the set expression at message threw an exception at line 6:

io.toro.gloop.exception.GloopException: groovy.lang.MissingPropertyException: No such property: name for class: Script1
    at NaughtyExpression.Set(NaughtyExpression.gloop:3)[message]:6]

The second line in the stacktrace tells us the name of the Gloop service that threw the error, which step, and which specific line number.

    at <Name of service>.Set(<Name of service>.gloop:<Line number of set step>)[<Name of variable>]:<Line number which threw the exception>]

Here is a screenshot showing the set step:

The set step with error

The set step with error

Errors in set expressions

Exceptions are thrown at runtime if your set step has a syntax error. Like any other exception, they will be caught by any parent block step with a catch.

Declaring variables

Gloop lets you declare variables in a map step. Similar to Java, variables have a concept of scope, meaning that if you declare a variable in a nested block step, then its parents will not see the declared variable. In Coder, there are four ways in which you can declare a variable:

  • The context menu of the Mapper view's Output side
  • Hotkeys (e.g. will declare a new string);
  • Pressing the full-stop key, which will bring up the content assist feature (unsupported by Coder Cloud)
  • Dragging and dropping a model from the Coder Navigator view to the Mapper view

The GIF below shows all four methods, in order:

Four ways of declaring variables in Gloop

Four ways of declaring variables in Gloop

Unloading variables

Gloop also lets you remove declared variables once you're finished with them. This feature is useful in helping keep the Mapper view in Coder nice and clean, and also makes Gloop code easier to read. When a variable is unloaded, it will not show in the Mapper for any steps after the step that has unloaded it. To unload a declared variable, right click on it, then select Unload Property, or press .

Unloading a variable

Unloading a variable

Rules for declaring and unloading variables

Gloop lets you declare and unload variables in map and invoke steps only.