# Programable Email & Displaying Associated Deals

**URL:** <https://community.hubspot.com/t/programable-email-displaying-associated-deals/138717>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [August 28, 2025, 3:06pm UTC](https://community.hubspot.com/t/programable-email-displaying-associated-deals/138717 "2025-08-28T15:06:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NCiprich](https://avatars.discourse-cdn.com/v4/letter/n/ecae2f/32.png) [@NCiprich](https://community.hubspot.com/u/NCiprich)\
**Post date:** [August 28, 2025, 3:06pm UTC](https://community.hubspot.com/t/programable-email-displaying-associated-deals/138717/1 "2025-08-28T15:06:17Z")

</div>

Hi,  
(Not a developer, but tasked to develop)  
I’m trying to create a programble email module that displays all the associated deals to the recipient that meet a few filter criteria. It doesn’t need to look super nice, but all I need is a table that shows the deal claim number in one column and a hyperlink to a form with some of the fields dyncamically filled in the other column.  
This is what I have so far, but nothing is rendering in the email tests I send myself. The fallback message is not even displaying. Hoping someone can please tell me what is wrong/missing, or if this can’t work in email.  
In the design manager I’m seeing this warning:  
Warning: 9:1 DEAL objects can only be retrieved on membership or password-restricted pages  
I asked support about this and they ensured it should work in email and my code is the issue.

{% set deal\_ids = crm\_associations(contact.hs\_object\_id, “HUBSPOT\_DEFINED”, 4) %}

{% set matching\_deals = [] %}  
{% set cutoff\_date = 1745020800000 %} {# 2025-04-19 in ms since epoch #}

{% for deal\_id in deal\_ids %}  
{% set deal = crm\_object(“deal”, deal\_id,  
“dealname,hubspot\_auto\_msa\_trigger,referral\_date,status,dyn365\_opportunity\_id,claim\_number”)  
%}

{# Ensure referral\_date exists and is BEFORE cutoff #}  
{% if deal.hubspot\_auto\_msa\_trigger == “Auto-MSA Start”  
and deal.status == “Open”  
and deal.referral\_date and deal.referral\_date|int \< cutoff\_date %}  
{% do matching\_deals.append(deal) %}  
{% endif %}

{% if matching\_deals|length \>= 10 %}  
{% break %}  
{% endif %}  
{% endfor %}

{% if matching\_deals|length \> 0 %}  
\<table style=“width:100%; border-collapse: collapse;”\>  
\<thead\>  
\<tr\>  
\<th style=“border: 1px solid #ccc; padding: 8px; text-align: left;”\>Deal Name\</th\>  
\<th style=“border: 1px solid #ccc; padding: 8px; text-align: left;”\>Case Update Link\</th\>  
\</tr\>  
\</thead\>  
\<tbody\>  
{% for deal in matching\_deals %}  
\<tr\>  
\<td style=“border: 1px solid #ccc; padding: 8px;”\>{{ deal.dealname }}\</td\>  
\<td style=“border: 1px solid #ccc; padding: 8px;”\>  
\<a href=“[https://hubspotformplaceholder.com/case-update/?id=](https://hubspotformplaceholder.com/case-update/?id=){{ deal.dyn365\_opportunity\_id }}&claim\_number={{ deal.claim\_number }}” target=“\_blank”\>  
Update Case  
\</a\>  
\</td\>  
\</tr\>  
{% endfor %}  
\</tbody\>  
\</table\>  
{% else %}  
\<p\>No matching deals found.\</p\>  
{% endif %}

---

<div class="post-metadata">

**Author:** ![Adesignl](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/adesignl/32/27362_2.png) [@Adesignl](https://community.hubspot.com/u/Adesignl)\
**Post date:** [August 28, 2025, 4:23pm UTC](https://community.hubspot.com/t/programable-email-displaying-associated-deals/138717/2 "2025-08-28T16:23:00Z")

</div>

Are you sure the Association ID is 4?

`{% set deal_ids = crm_associations(contact.hs_object_id, "HUBSPOT_DEFINED", 4) %}`

---

<div class="post-metadata">

**Author:** ![NCiprich](https://avatars.discourse-cdn.com/v4/letter/n/ecae2f/32.png) [@NCiprich](https://community.hubspot.com/u/NCiprich)\
**Post date:** [August 28, 2025, 5:12pm UTC](https://community.hubspot.com/t/programable-email-displaying-associated-deals/138717/3 "2025-08-28T17:12:08Z")

</div>

Everything i’ve read says 4 is the association id between the standard contacts and deals. I’m not sure how to confirm that, but I know we are using standard contacts and deals.

---

<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 28, 2025, 5:55pm UTC](https://community.hubspot.com/t/programable-email-displaying-associated-deals/138717/4 "2025-08-28T17:55:22Z")

</div>

Hey, @NCiprich 👋 Is this close to the outcome you are after?

 ![CleanShot%202025-08-28%20at%2011.33.27%402x.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/b/3/b3e6652633074f484571839647520ba93350266f.png)

Talk soon! — Jaycee

---

<div class="post-metadata">

**Author:** ![NCiprich](https://avatars.discourse-cdn.com/v4/letter/n/ecae2f/32.png) [@NCiprich](https://community.hubspot.com/u/NCiprich)\
**Post date:** [August 28, 2025, 6:01pm UTC](https://community.hubspot.com/t/programable-email-displaying-associated-deals/138717/5 "2025-08-28T18:01:05Z")

</div>

Hi Jaycee, yes that is what I am looking to accomplish!
