# Variable Substitution in Workflow Engine Actions

In some cases you want a variable or dynamic value for a function parameter in the Workflow Engine for Moogsoft Enterprise. 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: