Good resource for writing programmable automation in workflows?

For searching through a custom object like “brands”, you can utilize the searchApi function from the crm.objects module of the HubSpot API. This function allows you to provide a set of search parameters and retrieve custom objects that match these criteria directly, without needing to retrieve all objects and filter them afterwards.

A generic example would look something like this:

async function searchCustomObjects() {

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

const hubspotClient = new hubspot.Client({

accessToken: ‘YOUR_API_KEY’

});

const objectType = “Custom_Object_Internal_Name”;

const searchParams = {

filterGroups: [{

filters: [{

value: ‘Test 1’,

propertyName: ‘Custom_Object_Property’,

operator: ‘EQ’

}]

}],

sorts: [],

properties: [‘brand_name’],

limit: 10,

after: 0

};

try {

const apiResponse = await hubspotClient.crm.objects.searchApi.doSearch(objectType, searchParams);

console.log(apiResponse.results);

} catch (e) {

console.error(e);

}

}

searchCustomObjects();