Hello,
my requirement is to get a few of the deal-associated company properties in a callback function whose values would be used in the next action of workflow. I have developed half of the code but couldn’t complete it. It would be helpful if anyone could assist with this.
Code:
exports.main = async (event, callback) => {
const hubspotClient = new hubspot.Client({
apiKey: process.env.HAPIKEY_APP
});
var options = {
method: ‘GET’,
url: ‘https://api.hubapi.com/crm/v3/objects/deals/‘+event.inputFields[‘hs_object_id’]+’/associations/company?limit=500’,
headers: {
‘Authorization’: ‘Bearer pat-na1-YOUR-TOKEN’,
‘Content-Type’: ‘application/json’
},
body: JSON.stringify({
//write code?
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log("STATUS: " +response.statusCode);
console.log("HEADERS: " +JSON.stringify(response.headers));
console.log("BODY: " +response.body);
var parseBody = JSON.parse(response.body);
var keysArray = Object.keys(parseBody);
callback({
outputFields: {
//??? what to write
}
})
});
}