Custom Code Workflow Action in Sparkforge
The Custom Code action runs JavaScript inside a workflow step. Map values from earlier steps as inputData, run your logic, and assign the result to output for downstream actions.
The Custom Code action lets a workflow execute JavaScript so you can extend logic past what built-in actions cover. Map values from previous steps as inputs, transform them, and return an object the rest of the workflow can read.
How to configure
- Action Name: a label that says what the code does.
- Language: JavaScript. No other languages are supported right now.
- Property to Include in Code: add key-value pairs. The value can be hardcoded or pulled dynamically from a previous step. Reference each one in code as
inputData.<key>. If the key isnumber1, you read it asinputData.number1. - Code: JavaScript that processes the inputs. The result must be assigned to
outputas a JavaScript object or array of objects.
Field reference
| Field | Description | Required |
|---|---|---|
| Action Name | Display name of the step in the workflow. | Yes |
| Language | Defaults to JavaScript. | Yes |
| Property To Include In Code | Keys mapped from earlier steps; access them via inputData.keyName. | Yes |
| Code | JavaScript that produces the output object. | Yes |
Example
// Wrapped in an async function for you
const sum = inputData.number1 + inputData.number2;
output = { result: sum };This adds two mapped numeric inputs and returns the sum on output.result, which downstream steps can reference.
Notes
- Always assign the final value to
output. A return statement alone is not enough. - If the result is missing or malformed, downstream steps that depend on it will fail or skip.
- Keep the code small and deterministic. For long-running calls, use a webhook step instead.
Frequently Asked Questions
What languages does the Custom Code action support?
JavaScript only. No other runtimes are available at this time.
How do I read values from earlier workflow steps?
Add them under Property to Include in Code, then reference them as inputData.keyName in your script.
How do I return data to the next workflow step?
Assign your result to the output variable as an object or array of objects, e.g., output = { result: sum };.
Can I make external API calls from Custom Code?
For long-running or external HTTP work, the dedicated webhook action is a better fit. Custom Code is intended for in-line transforms.
Was this article helpful?
Thanks for the feedback.