Skip to main content
This feature only applies to Embedded iPaaS

Overview

The Custom Code connector is designed for simple data transformations within workflows. It executes vanilla JavaScript in a Promise environment, allowing you to manipulate data between workflow steps.

Use Cases

Custom Code is ideal for:
  • Data transformations (formatting, filtering, mapping)
  • Conditional logic beyond standard blocks
  • Array/object manipulations
  • Data validation and cleanup
Note:Axios requests are not supported in Custom Code. To make requests to third party APIs not directly supported via a dedicated connector, please use Custom API.

Accessing Workflow Data

Custom Code accesses workflow data through inputData. Variables mapped from previous workflow connectors become properties on this object, enabling data manipulation between connectors.

Example Usage of Custom Code

To start, create a workflow with Custom Event as your trigger. You can use any trigger, but we recommend using Custom Event to quickly test functionality and understand how Custom Code works. For the next connector, we’ll add a Shopify action. Select Get a list of all products as the action to pull all products from your Shopify catalogue. Now add the Custom Code connector. Select the variables output by the Shopify connector that you want to access within Custom Code. You can rename these variables for easier access. For example, we’re accessing the userId key output by the Shopify connector and assigning it to a variable named userId. We’re also taking the entire output of the Shopify connector and assigning it to a variable named productsData for quick access in Custom Code.
JavaScript
// Extract the dynamic inputs
const userId = inputData.userId; // Assuming userId comes from the Shopify connector source
const productsData = inputData.productsData; // Assuming productsData comes from the Shopify connector source

// Create the output object
const output = {
  userId: userId,
  type: "getProducts",
  products: productsData.products || [], // Ensure that productsData.products is used or default to an empty array
};

// Resolve the output
resolve(output);
Once you have added your variables and custom code, just hit next and you are all done! You can even check the sample output to see that it reflects example data. Simple enough, right? Now that you know how to properly use a Custom Code block, you are ready to explore all the possibilities that unlock with this feature.

Wrapping Up

That wraps up our walkthrough of the Custom Code block. If you were able to follow along and had a successful outcome, you are now a Custom Code expert. We can’t wait to see how you put this into everyday use!
I