Managing State & Variables

Workflows maintain state across asynchronous pauses using Context Variables.

Defining Variables

Before variables can be used in a workflow, they must be defined in the Variables array of the WorkflowDefinition.

"Variables": [
  { "Name": "ApprovalResult", "Type": "String" },
  { "Name": "DiscountApplied", "Type": "Decimal" }
]

Dynamic LINQ Expressions

When configuring nodes, you often need to evaluate conditions or assign values. Struktural uses Dynamic LINQ for runtime evaluation.

String Literal Escaping (CRITICAL)

Because expressions are evaluated inside JSON configuration strings, C# string literals MUST be escaped with double quotes. Single quotes (') are generally NOT supported for string literals in the expression parser.

Modifying State (ExpressionTransform Node)

To perform mathematical calculations or logic and store the result in a variable, use the ExpressionTransform node.

{
  "Id": "exp_1", 
  "Type": "ExpressionTransform", 
  "NextNodeId": "node_2", 
  "Configuration": {
    "TargetVariable": "Variables.DiscountApplied", 
    "Expression": "@Entity.Amount * 0.15"
  }
}

Text Templating

Certain nodes that output human-readable text (like SendEmail or the TaskTitle in WaitForUserAction) support Handlebars-style token replacement instead of raw LINQ. In these fields, use {{token}}: