Variable Substitution in Workflow Engine Actions

The parameters for the functions that make up Moogsoft Enterprise Workflow Engine actions accept the following types of data:

  • string: abcdef

  • number: 123

  • JSON object: { “ab” : “cd” , “e” : [ “f” , “g” ] }

In some cases, a parameter refers to the value for a specific field. For example, in the setClass function, the parameter “class” is a string and expects a specific value. Other parameters require a field name for the in-scope object. For example the upperCase function requires the object field that contains the value to convert to uppercase.

Variable substitution support

In some cases you want a variable or dynamic value for the parameter. For example when setting the value for an alert class. You don't want to specify a single class for all alerts, but you want to dynamically set the class based on an the value of an existing custom_info value.

Workflow Engine string and JSON object parameters accept macro syntax to allow for variable substitution. The Workflow Engine calculates the specific value for the parameter at runtime based upon the value of the in-scope object or the workflow context.

The workflow context is a JSON object where you can store data temporarily during workflow execution. The workflow context is useful for data you may need to use to construct the value of a field or for data you want to pass to another workflow, but which you do not want to store in the in-scope object.

Number type parameters do not support variable substitution. The UI validation prevents macro syntax for number parameters.

Variable substitution and macro syntax

The syntax for substitution is as follows:

$MACRO(<object field>)

For example: $EXPAND(severity) substitutes the severity name for the current object as the value. For example: Critical for severity 5. See Macros Reference for syntax for specific macros.

When to use variable substitution

In general consider using variable substitution when a function requires a “value”. For example setClass or appendString.

If a parameter requires a field name, variable substitution is unlikely to be appropriate. For example upperCase.

See the following examples that show the usage for variable substitution in different scenarios: