When to use
- Transform data into custom formats for external APIs
- Filter and process large datasets from API responses
- Perform complex calculations on records or metrics
- Validate and clean data before sending to external systems
- Integrate with external libraries for specialized processing
Input parameters
Key-value pairs of data passed into your custom function as the
params object. Include variables from previous nodes or static values needed for processing. Example: {"vendor": "{{sap_vendor}}", "threshold": 75}Programming language for your code. Options:
JavaScript, Python.Your custom code logic written inside the
yourFunction wrapper. The function receives input parameters as arguments and should return an object with your processed data.Your code must be written inside the
yourFunction wrapper. The function receives input parameters as arguments and should return an object with your processed data.Supported libraries
JavaScript libraries
| Library | Description | Import |
|---|---|---|
| axios | HTTP client for API requests | const axios = require('axios'); |
| lodash | Utility library for data manipulation | const _ = require('lodash'); |
| cheerio | Server-side jQuery for HTML parsing | const cheerio = require('cheerio'); |
| date-fns | Date utility library | const { format } = require('date-fns'); |
| fast-xml-parser | Fast XML to JSON converter | const parser = require('fast-xml-parser'); |
| fuse.js | Fuzzy search library | const Fuse = require('fuse.js'); |
| uuid | Generate RFC-compliant UUIDs | const { v4: uuidv4 } = require('uuid'); |
| mime | MIME type utilities | const mime = require('mime'); |
| number-to-words | Convert numbers to words | const converter = require('number-to-words'); |
| url | URL parsing utilities | const url = require('url'); |
| danfo | Data analysis library (pandas-like) | const dfd = require('danfojs-node'); |
Python libraries
| Library | Description | Import |
|---|---|---|
| pandas | Data analysis and manipulation | import pandas as pd |
| numpy | Numerical computing | import numpy as np |
| requests | HTTP library | import requests |
Need additional libraries? Contact our support team to request additional library support for JavaScript or Python.
Output
The Custom Code node outputs the exact return value from your custom function.- Direct Output: Whatever you return from
yourFunctionbecomes the node output - JSON Serializable: Return values must be JSON serializable (objects, arrays, strings, numbers, booleans)
- Error Handling: Runtime errors will be captured and displayed in workflow logs
Adding to your workflow
Add the node
Click Add Node in the workflow canvas, select Custom Code from the list of available nodes, then position it in your workflow.
Configure input parameters
Define the data to pass into your function as key-value pairs. Include variables from previous nodes and any static values needed for processing.
Select programming language
Choose JavaScript for web-focused processing or Python for data analysis and scientific computing.
Write your custom code
Implement your logic inside the
yourFunction wrapper. Access input parameters through function arguments and return an object with your processed results.Examples
Transform SAP Vendor Data for External API
This example processes SAP vendor data and categorizes it for external API integration: Input Parameters:Enrich NetSuite Customer Data with External API
This example enriches customer data by calling an external company information API: Input Parameters:Analyze Order Data with Python
This example analyzes order data using Python pandas: Input Parameters:Best practices
- Keep functions focused: Break complex logic into smaller operations
- Handle errors gracefully: Use try-catch blocks for external API calls
- Return structured data: Always return objects that other nodes can consume
- Use efficient algorithms: Optimize for performance within timeout limits
- Log debug information: Use console.log for troubleshooting
Troubleshooting
| Problem | Solution |
|---|---|
| Code execution timeout | Optimize algorithms, reduce complexity, break into multiple nodes |
| Library import error | Check library name spelling, verify library is supported, use correct import syntax |
| Runtime error | Add try-catch blocks, validate input parameters, check for null values |
| Memory limit exceeded | Process data in smaller chunks, avoid storing large objects, use streaming approaches |
Next steps
Transform node
Run simpler JSONata-based transformations.
HTTP node
Call external APIs without custom code.
Rule node
Add conditional logic around custom code.
Loop node
Process arrays with custom code.