javascript
Executes custom JavaScript code with access to all workflow variables. The script must define aservflowRun function that receives the workflow context and returns a result.
Script
The JavaScript code to execute. Must contain aservflowRun function.
The
servflowRun function receives a vars object containing:
- Results from previous actions (e.g.,
vars.fetch_users) - Request parameters accessible via the workflow context
Dependencies
Bundled JavaScript dependencies to include with the script.Example
Basic transformation:Complex Calculations
Perform calculations on workflow data:Data Validation
Validate and sanitize input data:Array Filtering and Sorting
Filter and sort data:static
Returns a static value or a computed value using template syntax. Useful for setting constants, combining values, or preparing data for subsequent actions.Return Value
The value to return. Supports template syntax for dynamic values.Example
Return a constant value:Combine Values
Combine multiple values into a single result:Prepare Data
Prepare a JSON structure for another action:Set Default Values
Provide fallback values using template functions:When to Use Each
Next Steps
Data Operations
Fetch and store the data you transform.
Flow Control
Run transformations in parallel.
AI Agents
Combine transformations with AI processing.
Actions Overview
Learn the fundamentals of ServFlow actions.