Expression helpers

In addition to the standard library modules, Workflows supports a number of other built-in helper functions such as for data type and format conversions.

For examples, see the Syntax cheat sheet.

Conversion functions

Convert values from one data type to another.

Functions
double() Accepts an attribute of type string or integer and returns a double.
int() Accepts an attribute of type string or double and returns an integer.
string() Accepts an attribute of type integer, double, or boolean and returns a string.

Data type functions

Operate on lists, maps, and strings.

Functions
in() Checks whether a given key is present in a list or map. See Check existence of a key in a list or Check existence of a key in a map.
keys() Accepts an attribute of type map and returns a list of key elements in the map.
len()

Computes the length of a value according to its type. Accepts an attribute of type list, map, or string and returns an integer.

  • A list returns the number of elements in the list.
  • A map returns the number of key-value entries stored in the map.
  • A string returns the number of characters in the string.

Conditional functions

Support conditions within expressions.

Functions
default(val, defaultVal)

Returns a value if it is not null; otherwise returns a default value.

  • If not null, val is returned.
  • If val is null, defaultVal is returned.

You can use default with the standard library function, map.get, to safely access optional values in a map, returning null if the key is not found. For an example, see Read map values.

You can also use default to access optional runtime arguments, and return a default value if the key is not found. For an example, see Access runtime arguments.

if(condition, ifTrue, ifFalse)

Evaluates a condition and returns one of two arguments depending on what the condition evaluates to.

  • If condition evaluates to true, ifTrue is returned.
  • If condition evaluates to false or null, ifFalse is returned.

Note that arguments passed to if are always evaluated and that the function does not control processing flow. To conditionally execute an expression, use a switch statement. For more information, see Conditions.

Type functions

Return data type.

Functions
get_type(arg)

Returns a string indicating the data type of arg: one of boolean, bytes, double, integer, list, map, string, or null.

If the operand is a function or a subworkflow, a TypeError is raised.