Action Elements
Elements for executing actions and modifying state
Action Elements
Action elements are used to perform operations and modify state within your workflow.
Available Elements
Assign
The <assign>
element modifies data model values. Use it to update state, increment counters, or append to arrays.
Log
The <log>
element outputs messages for debugging and tracing. Essential for development and troubleshooting.
Script
The <script>
element executes JavaScript code. Useful for complex logic and computations.
Cancel
The <cancel>
element cancels delayed events. Important for cleanup and workflow control.
Common Use Cases
-
State Management
-
Debugging
-
Complex Logic
-
Event Control
Best Practices
-
State Modifications
- Use assign for simple state updates
- Use script for complex calculations
- Validate data before modifications
- Keep state changes atomic
-
Event Handling
- Cancel delayed events when appropriate
- Handle errors gracefully
-
Debugging
- Use log elements strategically
- Include relevant context in logs
- Consider log levels
- Clean up debug logs in production
-
Code Organization
- Keep scripts focused and modular
- Document complex operations
- Use meaningful identifiers
- Follow consistent patterns