Run Your Own JavaScript with the Custom Code Action

When no built-in action does exactly what you need, the Custom Code action lets you write a short JavaScript snippet that runs as a workflow step and returns data to later steps.

Set it up

  1. Click + in your workflow and choose Custom Code.
  2. Under Properties to include, click Add Property for each value you need. Give it a Key and pick its value from the merge field picker.
  3. In the editor, write your code. A sample is pre-filled. Read inputs with inputData.keyName or inputData['keyName'].
  4. Return your result as an object or a list of objects.
  5. Use HTTP Request above the editor to insert a ready-made GET, POST, PUT, PATCH, DELETE, HEAD, or OPTIONS call.
  6. Use Format Code to tidy indentation.
  7. Click Test your Code.

Testing is required

Output from untested code is not available to later steps. In the test window, fill in sample values on the Test Setup tab if you added properties, then run it. You will see Test Result Success or Test Result Failed. Only contact information is passed during a test, so merge fields from elsewhere need sample values. Anything you send to the console appears in the test output, which helps with debugging.

Build with AI

Click Build with AI, describe what you need in plain language, and click Generate. Ask for changes in the text box and Regenerate, then Use Code when it looks right. Specific prompts work best: "My API returns dates as MM-DD-YYYY; convert them to YYYY-MM-DD." Always read generated code before using it.

Good uses

  • Reformat phone numbers or dates.
  • Call an outside API and use the response.
  • Do custom calculations or text extraction.
  • Route leads with multi-part rules.

Check inputs later

If results look off, open the contact's execution in the logs and select More Details to see the exact input values.

Good to know: Keep snippets short and single-purpose; several small code steps are easier to debug than one large one.

Was this article helpful?