# HubL Functions

**URL:** <https://community.hubspot.com/t/hubl-functions/47941>\
**Category:** CMS Development\
**Tags:** enterprise\
**Created:** [December 3, 2021, 10:49am UTC](https://community.hubspot.com/t/hubl-functions/47941 "2021-12-03T10:49:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AZbarouski](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AZbarouski](https://community.hubspot.com/u/AZbarouski)\
**Post date:** [December 3, 2021, 10:49am UTC](https://community.hubspot.com/t/hubl-functions/47941/1 "2021-12-03T10:49:30Z")

</div>

Hi!

I have a problem!

I read the info on how to work with **crm\_associations** here [HubL functions - HubSpot docs](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 variable in **the crm\_associations** function? Is it finally possible?

The same problem with **crm\_object** [HubL functions - HubSpot docs](https://developers.hubspot.com/docs/cms/hubl/functions#crm-object) **,** I can’t use the **query** dynamically.

**{% set deal = crm\_object(“deal”, deal.hs\_object\_id) %}**

**{{ deal }}**

---

<div class="post-metadata">

**Author:** ![natsumimori](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/natsumimori/32/39807_2.png) [@natsumimori](https://community.hubspot.com/u/natsumimori)\
**Post date:** [December 6, 2021, 3:51am UTC](https://community.hubspot.com/t/hubl-functions/47941/2 "2021-12-06T03:51:00Z")

</div>

Hi @AZbarouski , thank you for your post.

I wanted to tag in @Indra and @miljkovicmisa who have shared great knowledge around Hubl in the Community. Would you be able to weigh in here?

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [December 6, 2021, 7:27am UTC](https://community.hubspot.com/t/hubl-functions/47941/3 "2021-12-06T07:27:00Z")

</div>

Hi @AZbarouski ,  
I had this working with retrieving associated objects with a contact ID. I used the [programmable email beta](https://knowledge.hubspot.com/email/create-programmable-emails) 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.

---

<div class="post-metadata">

**Author:** ![natsumimori](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/natsumimori/32/39807_2.png) [@natsumimori](https://community.hubspot.com/u/natsumimori)\
**Post date:** [December 7, 2021, 3:35am UTC](https://community.hubspot.com/t/hubl-functions/47941/4 "2021-12-07T03:35:26Z")

</div>

Thank you @Teun 😄

---

<div class="post-metadata">

**Author:** ![MRenders](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mrenders/32/22074_2.png) [@MRenders](https://community.hubspot.com/u/MRenders)\
**Post date:** [May 11, 2022, 12:19pm UTC](https://community.hubspot.com/t/hubl-functions/47941/5 "2022-05-11T12:19:55Z")

</div>

Hi @Teun,

Could you provide this code, if you still have it, as an example? I’m also struggeling with this.

Thank you 😄

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [May 12, 2022, 6:09am UTC](https://community.hubspot.com/t/hubl-functions/47941/6 "2022-05-12T06:09:45Z")

</div>

Hi @MRenders ,

If you activate the programmable email beta for your custom module, then this should work:

```lia-code-sample
{% 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:

```lia-code-sample
{% set lineitems = crm_associations(deal.hs_object_id, "HUBSPOT_DEFINED", 19, "limit=50",
"description,quantity", false) %}

```

This will give you the unformatted data, which solved a few bugs I had.

---

<div class="post-metadata">

**Author:** ![JLoomis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jloomis/32/31184_2.png) [@JLoomis](https://community.hubspot.com/u/JLoomis)\
**Post date:** [August 7, 2025, 3:37pm UTC](https://community.hubspot.com/t/hubl-functions/47941/7 "2025-08-07T15:37:38Z")

</div>

Hello,

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\>

```  
Workflow output:

 ![Screenshot 2025-08-07 at 10.36.01 AM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/5/450de9a787ae642224c19671df0378137575e23e.png)

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.

Thank you for your help.

Joseph

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 7, 2025, 5:09pm UTC](https://community.hubspot.com/t/hubl-functions/47941/8 "2025-08-07T17:09:54Z")

</div>

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
