Custom Code Test for Operations Hub is Not pulling in Data

From Jack’s tutorial on data Enrichment using Clearbit:

Only the Domain Aliases are pulling into my company CRM. Im getting error mesages in my action log

Here is my code:

const request = require(‘request’);

exports.main = async (event, callback) => {

//1. Store the company domain in a variable
var companyDomain = event.inputFields[‘domain’];
var domainAlias, tech, subIndustry, legalName;
//2. Configure request to Clearbit Discovery API
var options = {
“method”: “GET”,
“url”: “https://company.clearbit.com/v2/companies/find?domain=” + companyDomain,
“headers”: {
“Authorization”: “Bearer " + process.env.APIKEY
}
}
//3. Make request to Clearbit Discovery API
request(options, function (error, response, body){
//4. Store the data returned in variables
domainAlias = JSON.parse(body).domainAliases.join(”,“); // Domain Aliases
tech = JSON.parse(body).tech.join(”,"); // Tech
subIndustry = JSON.parse(body).category.subIndustry; // Industry
legalName = JSON.parse(body).legalName; // Legal Name
//5. Pass data back to workflow for later use
callback({
outputFields: {
domainAliases: domainAlias,
tech: tech,
subIndustry: subIndustry,
legalName: legalName
}
});
});
}

here is my workflow

Hi @SCarducci,

Thanks for joining the session, I hope you found it useful. I’ve taken a look at this for you and I know the issue!

You need to make sure to define the output “tech” in the outputFields block in the code using the same name you used in the data outputs form. If we look at your current setup there is a small typo, notice the capitalisation of “Tech” in “Data Output” but in the callBack block within the code it’s lowercase “tech”.

The good news is that you are getting all of the data from Clearbit (so congrats on making a successful request using a custom coded action) and all you need to do here is ensure both match i.e set them to “tech” in both callback and data output.

iss

I hope this helps and happy coding!

Jack

That fixed the issue. The data is now pulling in correctly, and everything is working as expected.

snap planets

This does a great job of explaining the concept. The clarity and depth make it stand out.

status check

If you’re experiencing issues where a custom code test in HubSpot’s Operations Hub isn’t pulling in data, there are several potential reasons and solutions to investigate:

1. Incorrect or Missing Data Mappings

  • Cause: The custom code may not be properly set up to receive the required data inputs.
  • Solution: Double-check that the input data mappings (from workflows or triggers) match the expected structure within the custom code block. Ensure that all necessary properties are mapped correctly and available for the code to process.

2. API or Third-Party Integration Errors

  • Cause: If the custom code involves pulling data from an external API or third-party service, there might be issues with API connectivity, authentication, or request parameters.
  • Solution: Verify that the API endpoints being called are functioning correctly. Ensure your API keys or OAuth tokens are up to date and that rate limits are not exceeded. Use logs to confirm the API request is being made and receiving the expected responses.

It sounds frustrating when the custom code test for Operations Hub isn’t pulling in data. :hammer_and_wrench: Have you checked for any API limitations or data formatting issues? Sometimes, similar challenges arise in large-scale systems like the 8171 Ehsaas Program, where data integration plays a crucial role in ensuring smooth operations.

Thanks for sharing it really helped me. Its fixed now

sso