I read the info on how to work with crm_associations here https://developers.hubspot.com/docs/cms/hubl/functions. As I see from the documentation there are 3 main properties "id, association category, association type id".
I know how to use association category and association type id, it's clear. The main problem is in id I want to use it dynamically. I don't have the id of the deal, for example, 1234, I just know the property deal.hs_object_id, and where this property stores. deal.hs_object_id is always different because I sent the email to the different users with different ids.
I want to to use crm_associations like this crm_associations(deal.hs_object_id, 'HUBSPOT_DEFINED', 5), not like this crm_associations(1234, 'HUBSPOT_DEFINED', 5).
My question is, how can I use deal.hs_object_id as a variablein the crm_associations function? Is it finally possible?
If you activate the programmable email beta for your custom module, then this should work:
{% set lineitems = crm_associations(deal.hs_object_id, "HUBSPOT_DEFINED", 19, "limit=50",
"description,quantity") %}
In my case, I retrieve the associated line items, but you should be able to get different objects this way as well. If you have any bugs with the data or the email, try setting a third param:
I had this working with retrieving associated objects with a contact ID. I used the programmable email beta with a custom module. I first set the contact ID to a custom variable and then used it to retrieve the associated custom objects. I'll see if I can retrieve the code from an old sandbox.
Learn more about HubSpot by following me on LinkedIn or YouTube
✅ Did my answer solve your issue? Help the community by marking it as the solution.
If you activate the programmable email beta for your custom module, then this should work:
{% set lineitems = crm_associations(deal.hs_object_id, "HUBSPOT_DEFINED", 19, "limit=50",
"description,quantity") %}
In my case, I retrieve the associated line items, but you should be able to get different objects this way as well. If you have any bugs with the data or the email, try setting a third param: