I was tryning to fetch all contacts whose association.company property is equal to the externalId ( eg- 18363096664 ), but this filter section is causing some issue while running the code and it’s working when it’s commented, means there is some issue with the property name equality check. Can anyone please help me out to resolve this issue.
Below is the query that I an using.
const response = await hs.crm.contacts.searchApi.doSearch({
limit: 200,
properties: [
“email”,
“ext_”,
“firstname”,
“hs_additional_emails”,
“hs_marketable_status”,
“hs_marketable_until_renewal”,
“hs_object_id”,
“lastmodifieddate”,
“lastname”,
“mobilephone”,
“phone”
],
filterGroups: [
// Filter groups are ORed together.
{
filters: [
// Filters are ANDed together.
// {
// propertyName: “associations.company”,
// value: entity.externalId,
// operator: FilterOperatorEnum.Eq
// },
]
}
]
})
Just to double check that it’s not a encoding error.
Try removing the “,” (comma) you have after the “}” (bracket) in the filters. JSON would not expect a comma there unless you have another filter.
const response = await hs.crm.contacts.searchApi.doSearch({
limit: 200,
properties: [
"email",
"ext_",
"firstname",
"hs_additional_emails",
"hs_marketable_status",
"hs_marketable_until_renewal",
"hs_object_id",
"lastmodifieddate",
"lastname",
"mobilephone",
"phone"
],
filterGroups: [
// Filter groups are ORed together.
{
filters: [
// Filters are ANDed together.
{
propertyName: "associations.company",
value: entity.externalId,
operator: FilterOperatorEnum.Eq
}
]
}
]
})
Hi,
Sorry for confusion, thats just a typing mistake here, while in my code it’s properly monitored for the proper JSON format.
Please explain to me that where can I found the association.company property in my Contacts in Hubspot , is this exist in PropertyName or Association section?
That’s your code I repasted. I just tidied it up to make it easier to read and removed the errant comma that might have been the issue.
The Search API has the functionality to search through associations:
It uses the notation “associations.{objectType}” for the propertyName as shown in their example.