Set Variable
Summary
- Internal name:
SetAndromateVariable - Category: Workflow Runtime
- Purpose: Assign a new value to an existing workflow variable at runtime.
- Task type: Normal
Compatibility
-
Minimum AndroMate version:
1.1.0 -
Maximum AndroMate version:
1.1.0 -
Minimum Android:
Android 13 (API 33) -
Maximum Android tested:
Android 16 (API 36) -
Supported manufacturers:
- ✅ All manufacturers
-
Required permissions:
- None
Detailed description
The Set Variable task updates the value of a workflow variable during execution. It allows dynamic modification of any variable that was declared in the Start node.
It is used to:
- Reset a variable to a fixed or computed value
- Copy the value of one variable into another
- Update a counter or accumulator between iterations
- Override an initial value based on a condition result
The task handles:
- validation that the target is a properly declared variable,
- resolution of the new value against the current execution context (other
$variablesare replaced with their current values), - update of the variable in the shared
AndroMateContext.
Input parameters
| Parameter | Type | Required | Possible values | Android Compatibility | AndroMate Compatibility | Default |
|---|---|---|---|---|---|---|
variable_input |
String | Yes | A declared variable name starting with $ |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | — |
variable_value |
String | Yes | Any string value, may contain $variable references |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | "" |
Output parameters
The Set Variable task produces no outputs. It modifies the execution context directly and returns immediately.
Exceptions
| Code | Exception Name | Description |
|---|---|---|
WORKFLOW-RUNTIME-001 |
Empty Variable Input | variable_input is empty or null. A valid variable name starting with $ is required. |
WORKFLOW-RUNTIME-002 |
Non-Variable Input | variable_input does not start with $. Only declared variables can be targeted. |
WORKFLOW-RUNTIME-002 |
Variable Not Defined in Runtime | The variable referenced in variable_input was not declared in the Start node. Declare it first. |
Execution flowchart
flowchart TD
Start([Start SetVariableTask]) --> ReadInput[📋 Read variable_input\nno resolution applied]
ReadInput --> CheckEmpty{variable_input\nempty or null?}
CheckEmpty -->|Yes| E1[❌ WORKFLOW-RUNTIME-001\nSET_EMPTY_VARIABLE]
CheckEmpty -->|No| CheckIsVar{variable_input\nstarts with $ ?}
CheckIsVar -->|No| E2[❌ WORKFLOW-RUNTIME-002\nSET_NON_VARIABLE]
CheckIsVar -->|Yes| CheckDeclared{variable declared\nin runtime context?}
CheckDeclared -->|No| E3[❌ WORKFLOW-RUNTIME-002\nNO_VARIABLE_DEFINED_IN_RUNTIME]
CheckDeclared -->|Yes| ResolveValue[🔄 Resolve variable_value\nreplace $refs with current values]
ResolveValue --> SetValue[💾 androMateContext.setVariableValue\nvariable_input ← resolved value]
SetValue --> Success([✅ VoidResult\nVariable updated])
E1 --> Error([❌ Exception])
E2 --> Error
E3 --> Error
style Start fill:#e3f2fd
style Success fill:#c8e6c9
style Error fill:#ffcdd2
style ResolveValue fill:#fff9c4
style SetValue fill:#c8e6c9
style E1 fill:#ffcdd2
style E2 fill:#ffcdd2
style E3 fill:#ffcdd2
How it works:
- Read
variable_input: Loads the target variable name as a literal string — no variable resolution is applied at this stage - Empty check: Raises
WORKFLOW-RUNTIME-001if the input is empty or null - Variable format check: Raises
WORKFLOW-RUNTIME-002if the input does not start with$ - Declaration check: Raises
WORKFLOW-RUNTIME-002if the variable was not declared in the Start node - Resolve
variable_value: Evaluates the new value — any$variablereferences inside are replaced with their current runtime values - Update context: Writes the resolved value into
AndroMateContextfor the target variable - Result: Returns
VoidResult— the variable is now updated for all subsequent tasks
Legend: - 🔵 Blue: Start - 🟢 Green: Success - 🔴 Red: Exceptions - 🟡 Yellow: Resolution - 💾 Green: Context update
Input parameter details
1. Input parameter: variable_input
The name of the variable to update. Must be a variable declared in the Start node.
Example
Details
- Must start with
$. - The value is read as-is — no variable resolution is applied to this field. You must write the literal variable name (e.g.
$result), not a reference to another variable that holds a name. - The variable must have been declared in the
variablesarray of the Start node.
2. Input parameter: variable_value
The new value to assign to the variable. Can be a static string or contain references to other $variables.
Example — static value
Example — copy from another variable
Example — mixed
Details
- Variable references (
$name) inside this field are resolved at runtime before assignment. - The resolved value is always stored as a string in the context.