I read the info on how to work with crm_associations here HubL functions - HubSpot docs. 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 variable in the crm_associations function? Is it finally possible?
Hi @AZbarouski ,
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.
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 am still struggling with this. I am trying to retriever a company id from a ticket, but the email that has the module is refusing to compose with the following syntax:
```
{% set company_id = crm_associations(ticket.id,‘HUBSPOT_DEFINED’,339,“limit=50”,“hs_object_id”,false) %}
<div>
{{ company_id }}
</div>
Programmable email is on and the module is loaded in the email. The preview output appears to be blank, so I assume there is an error in the syntax, but the editor is not highlighting anything.
Hey, @AZbarouski Please consider making a new post for this question as this post is from 2021. You didn’t do anything wrong, and I want to make sure you get as many views as possible for your question. — Jaycee