Quick tipDeveloperData Hub

Custom code workflow actions: the basics that save debugging time

A few lines of Node.js inside a workflow can replace a middleware service.

Subscription
Data Hub Professional or Enterprise
Permissions
Workflows access
Time
5 min · Advanced
Last verified

Short answer

Custom code actions run Node.js by default. Properties come in through event.inputFields, and callback({ outputFields }) returns values that later actions can use, for example with Edit record. Keep tokens in secrets. HubSpot's docs say that to have a rate-limited call retried, you must throw the error in your catch block. Logs are in the workflow's action logs.

1. Where it is

Workflow action picker Data ops group with Custom code highlighted
Custom code (1).

2. The shape of the code

exports.main = async (event, callback) => {
  const email = event.inputFields['email'];
  try {
    // call another system here
    callback({ outputFields: { domain: email.split('@')[1] } });
  } catch (err) {
    // throw so HubSpot retries rate-limited calls
    throw err;
  }
};

3. Practical notes

  • Inputs and outputs are typed fields in the action panel. Declare outputs so other actions can see them.
  • Swallowing errors means no retry and a silent success.
  • Agent Hub workflows also support custom code. See agentic workflows.

Sources

New field notes by email

One email when a new article publishes.

Still stuck?

If this did not fix it, the problem is probably specific to your setup. Book a call and we will look at it together.

Book a call with Sam