Hi there, I’m sure I’m doing something wrong here but I’m always getting an empty properties field when using the useAssociations hook in a custom UI Extension.
Here’s my call:
const {
results,
error: associationsError,
isLoading: associationsLoading,
pagination,
refetch: refetchAssociations,
isRefetching: isAssociationsRefetching,
} = useAssociations(
{
toObjectType: "2-123456",
properties: ["hs_object_id", "name", "primary_contact"],
pageLength: 100,
},
{
propertiesToFormat: "all",
formattingOptions: {
date: {
format: "MM-DD-YYYY",
relative: false,
},
dateTime: {
format: "MM-DD-YYYY hh:mm",
relative: false,
},
currency: {
addSymbol: true,
},
},
}
);
The results contain the correct associationTypes array and toObjectId but the properties array is empty.
Couple of things I’ve already tried:
- I’m trying to get properties from an associated custom object, but I’ve also tested with contacts, deals and companies but all have the same result
- I’ve tried using the id and the string to reference the toObjectType (eg. ‘contacts’ and ‘0-1’, ‘companies’ and ‘0-2’) but both return the same result
- I’ve added the relevant scopes to the app-hsmeta.json
Any help is much appreciated!
Hi @DaganBPM
Thanks for sharing the code + what you’ve tried — that’s super helpful.
I’ll pull in a few Community members who are very familiar with UI Extensions + CRM hooks.
@MKatewa @IMakkar @HFisher7 — have you seen useAssociations return the correct toObjectId / association types but an empty properties array (even when requesting fields like hs_object_id, name, etc.)? Any known gotchas around required scopes, object type IDs (e.g., 2-xxxxx), or hook limitations that would explain why properties aren’t being hydrated?
Appreciate any insight you can share.
Best, Victor
Hey @Victor_Becerra it seems to be working now, I’m assuming HS fixed the bug on their end as I didn’t change anything and now the props are suddenly populating so that’s good!
I am doing something similar and properties for the associated object is not coming back despite the documentation saying it should:
const { results, error, isLoading, pagination, isRefetching, refetch } = useAssociations(
{
// Object type ID to fetch associations for
toObjectType: '0-2',
// Optional properties to fetch from associated objects
properties: ['shipping_street_adddress', 'shipping_city', 'shipping_state_region', 'shipping_postal_code'],
// Optional pagination settings
pageLength: 25,
},
// Optional formatting configuration (same as useCrmProperties)
{
propertiesToFormat: 'all',
formattingOptions: {
date: {
format: 'MM-DD-YYYY',
relative: false
},
dateTime: {
format: 'MM-DD-YYYY hh:mm',
relative: false
},
currency: {
addSymbol: true
}
}
}
);
....
{JSON.stringify(results)};
outputs:
[{"toObjectId":49203777804,"associationTypes":[{"category":"HUBSPOT_DEFINED","typeId":1299,"label":"Primary"},{"category":"HUBSPOT_DEFINED","typeId":1236,"label":""}],"properties":{}}];
An update on my post that may shed some light on yours: turns out if the property on the associated object doesn’t have a value set, then the hook doesn’t bother returning the property value. As soon as I entered a value for the requested property, the results object now has it:
[{"toObjectId":49203777804,"associationTypes":[{"category":"HUBSPOT_DEFINED","typeId":1299,"label":"Primary"},{"category":"HUBSPOT_DEFINED","typeId":1236,"label":""}],"properties":{"shipping_city":"Dallas"}}];
Thanks for the reply @darveesh, glad it was working for you, however this didn’t work for me when I initially posted as all of the fields I was trying to pull had data. I think they may have resolved the bug on their end as everything is working for me now without changes on my end!
I am also experiencing this. Unable to get hs_object_id returned when using useAssociations on a custom object.
It seems to be working for me now, I’m assuming they resolved the bug on their end as I haven’t made any changes!