Custom code for getting all associations

Hi Phil, Being straight to the point.. To modify your code and get all associations regardless of their labels, we can use the HubSpot Associations API in version 4. If you have installed and set up the required components properly, you should run this code in an environment that can handle HubSpot API calls. Below is an updated version of your code that fetches all associations using the v4 Associations API:

const hubspot = require('@hubspot/api-client');

exports.main = (event, callback) => {
 const hubspotClient = new hubspot.Client({ accessToken: process.env.private_app_token });

 // First, make a call to get deal associations to companies
 hubspotClient.crm.v4.associationsApi.readBatch({
 inputs: event.object.objectId.map(objectId => ({
 from: {
 id: objectId,
 type: 'deal'
 },
 to: {
 type: 'company'
 }
 }))
 }).then(results => {
 let companyPromises = results.body.results.map(item => {
 return hubspotClient.crm.companies.basicApi.getById(item.to.id, ['hs_object_id', 'type_of_company']).then(results => {
 return results.body
 });
 });

 Promise.all(companyPromises).then(companies => {
 callback(null, companies);
 }).catch(error => {
 callback(error);
 });
 }).catch(error => {
 callback(error);
 });
};

Let me know if anything bthers you!