Working with the operator element

The operator element lets us change the state of a value. We can do this with standard operations (like, add two values, or empty this value). We also have the option of using macro operations for more sophisticated operations (like, calculating a percentage, random number assignments, and so on).

What are some of the things an operator can do?

Set a value equal to another value.

Add/subtract a number (value) from another number (value)

Concatenate two string, content, or password values

Empty a value, by setting it to ‘Nothing’.

Set an object value to the ‘first’, ‘next’, or ‘last’ object from a list.

Set a number equal to the length of a string, content, password, or list (e.g. the number of objects in a list).

Execute a macro.

Override a navigation.

Operations in Flow are performed immediately on the state and execute within the platform without any user involvement.

What else?

The ordering of operations is important.
Each operation will be performed, in series, in the order it is designated (starting with the lowest order). If an operation has the same order as another, the platform will execute the operations in random order.

Operations that execute macros are ordered in relation to all operations, they are not executed separately. We can have a standard operation, then a macro operation, then standard operation executed in series.

When setting an object value equal to the ‘next’ object in a list value, the state tracks the current position in the list value. Say, a list contains three objects: A, B, and C. When the ‘next’ operation is executed the first time, it will retrieve object A. If another ‘next’ operation is executed on the same list, it will return object B. (The position in the list is managed by the list value, not the operation.)

When setting an object value equal to the ‘next’ object in a list value, the platform will return an empty object when the list is exhausted. If another ‘next’ operation is performed on the same list value, the list will reset back to the first object in the list value.

When setting an object value equal to the ‘first’ object in a list value, the state will set the position in the list value back to the first object. When setting to the ‘last’ object in a list value, the state will set the position in the list value to the last object.

Design thinking…

We can use an operator with a ‘next’ operation along with a decision, to iterate over list values. The decision should simply test if the object value is empty; and if so, follow a path that exits the loop. During each loop iteration, the flow can execute any map element and any number of map elements. There’s no requirement that the loop should finish.

If the standard operations do not provide enough functionality, we can use macros to change values in the state using logic written in JavaScript.

Macros are shared elements, and therefore can be shared across multiple flows. Aim to write macros that can be written once, and reused in subsequent flows.

Configuration options

Standard Operation

Setting

Description

Which value do you want to change?

The value that should be changed by the operation. This is the target value.

How do you want to change the value?

The way in which the value should be changed. This is the assignment. For example, ‘set equal to’, ’empty’, ‘add’, ‘subtract’, etc.

How do you want to retrieve the reference value?

The attribute of the value you want to get. For example ‘value of’, ‘length of’, etc. This is the command that will be executed on the source value.

Which value do you want to reference?

The value that should be referenced when performing the operation. This is the source value.

The order in which this operation should be performed

The order (starting at 0) in which to execute this operation in relation to other operations.

Macros

Setting

Description

Which macro do you want to run?

The macro that should be executed with this operation.

The order in which this macro should be evaluated

The order (starting at 0) in which to execute this operation in relation to other operations.