App Studio
Conditional Actions
Conditional actions use token expressions to decide at runtime whether to execute an action — enabling role-based interactions, state-dependent navigation, and guard conditions.
Conditional Action Config
// ConditionalActionConfig — if/then/else
{
"type": "conditional",
"condition": "{{ context.roles.includes('admin') }}",
"then": {
"type": "navigate",
"target": "/admin/settings"
},
"else": {
"type": "set-variable",
"variable": "accessDeniedMsg",
"value": "You need admin access to view settings."
}
}
Condition Expression Syntax
The condition field uses the same {{ }} token syntax as widget config properties. The expression must evaluate to a boolean-like value:
| Condition | Evaluates True When... |
|---|---|
{{ context.roles.includes('admin') }} | Current user has the admin role |
{{ variables.selectedId !== null }} | A row has been selected |
{{ route.id !== undefined }} | The URL has an id parameter |
{{ variables.formIsValid }} | The formIsValid variable is truthy |
{{ variables.count > 0 }} | Count variable is greater than zero |
Conditional Inside a Chain
// Conditional step inside a chain — route to different outcomes
{
"type": "chain",
"actions": [
{ "type": "trigger-workflow", "processId": "check-approval", "waitForCompletion": true, "input": { ... } },
{
"type": "conditional",
"condition": "{{ workflowOutput.approved }}",
"then": {
"type": "navigate",
"target": "/success"
},
"else": {
"type": "chain",
"actions": [
{ "type": "set-variable", "variable": "rejectionReason", "value": "{{ workflowOutput.reason }}" },
{ "type": "navigate", "target": "/rejected" }
]
}
}
]
}
Common Patterns
- Role guard: only admins see the delete confirmation modal
- Selection guard: navigate to detail only if a row is actually selected
- Validation guard: submit form only if a required variable is set
- Feature flag: show new workflow if
variables.featureEnabledis true
Conditional vs. visibilityExpression
Use visibilityExpression on a widget to hide/show it entirely. Use conditional actions when the widget should always be visible but its click behavior should differ based on conditions. For example, a Delete button is always shown but its onClick uses a conditional to open an admin confirm dialog vs. showing a "no permission" message.