Programable Email & Displaying Associated Deals

NCiprich
Participant | Platinum Partner
Participant | Platinum Partner

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={{ 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 %}

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Thought Leader

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

 

 

Talk soon! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




View solution in original post

4 Replies 4
Adesignl
Contributor | Partner
Contributor | Partner

Are you sure the Association ID is 4? 

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

 

0 Upvotes
NCiprich
Participant | Platinum Partner
Participant | Platinum Partner

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.

0 Upvotes
Jaycee_Lewis
Solution
Thought Leader

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

 

 

Talk soon! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




NCiprich
Participant | Platinum Partner
Participant | Platinum Partner

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

0 Upvotes