⚙ Operations Hub

SCarducci
Member

Custom Code Test for Operations Hub is Not pulling in Data

SOLVE

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

 

SCarducci_0-1643903265730.png

 

0 Upvotes
1 Accepted solution
jackcoldrick
Solution
HubSpot Employee
HubSpot Employee

Custom Code Test for Operations Hub is Not pulling in Data

SOLVE

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

issue.png

 

I hope this helps and happy coding!

 

Jack

 

 

 

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn

View solution in original post

1 Reply 1
jackcoldrick
Solution
HubSpot Employee
HubSpot Employee

Custom Code Test for Operations Hub is Not pulling in Data

SOLVE

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

issue.png

 

I hope this helps and happy coding!

 

Jack

 

 

 

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn