Actions108
- AI Actions
- Transcribe
- Detect Brand
- Extract Contact Information
- Mood Detection
- Detect Adult Content
- Enitity Detection
- Language Detection
- Too Long To Read
- Check Content Policy
- Detect Faces
- Generate Python Code
- Picture Text Recognition
- Detect Color
- Generate Image
- PDF OCR
- Translation
- Detect Email Type
- Generate Javascript Code
- Picture Object Recognition
- Business Actions
- Calculate Actions
- Code Actions
- Convert Actions
- Crypto Actions
- Date & Time Actions
- Generate Actions
- Image Actions
- Operator Actions
- PDF Actions
- Storage Actions
- Text Actions
- User Actions
Overview
This node provides a versatile "Code" resource with a "Javascript" operation that allows users to execute custom JavaScript code within the workflow. It is part of a larger toolbox node offering many utilities, but focusing on the "Code" resource and "Javascript" operation, it enables running user-defined JavaScript snippets dynamically.
Common scenarios include:
- Running custom data transformations or calculations not covered by built-in nodes.
- Implementing complex logic or algorithms inline without external services.
- Manipulating input data programmatically before passing it downstream.
For example, a user might write JavaScript code to parse and reformat JSON data, calculate new fields based on existing ones, or filter arrays according to custom criteria.
Properties
| Name | Meaning |
|---|---|
| Code | The JavaScript code snippet to execute. This is required and contains the logic to run. |
| Code Variables | A collection of named variables to pass into the JavaScript code. Users can define multiple variables with their names (or IDs) and values. These variables become accessible inside the code execution context. |
Output
The node outputs a JSON array where each element corresponds to the result of executing the JavaScript code for each input item. The exact structure depends on the user's code but typically includes any returned or computed data from the script.
If the code produces binary data, it would be included in the output's binary property, representing files or buffers generated by the script.
Dependencies
- Requires an API key credential for authentication with the underlying service powering the node.
- Relies on internal helper functions to send requests to the service endpoint that executes the JavaScript code.
- No additional external dependencies are needed beyond the configured API access.
Troubleshooting
Common issues:
- Syntax errors in the provided JavaScript code will cause execution failures.
- Referencing undefined variables if the "Code Variables" are not properly set.
- Passing incorrect types or malformed inputs to the code may lead to runtime errors.
Error messages:
- Errors thrown during code execution are captured and returned as error objects in the output if "Continue On Fail" is enabled.
- Typical error messages include syntax errors, reference errors, or service communication errors.
Resolution tips:
- Validate JavaScript syntax before running.
- Ensure all referenced variables are defined in "Code Variables".
- Use try-catch blocks inside the code for graceful error handling.
- Enable "Continue On Fail" to prevent workflow interruption and inspect error details.
Links and References
- n8n Expressions Documentation — for using expressions to define variable values.
- General JavaScript documentation for writing valid scripts: https://developer.mozilla.org/en-US/docs/Web/JavaScript
This summary focuses exclusively on the "Code" resource with the "Javascript" operation as requested.