web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Get rows count from related record (1:N) in marketing email code block

(0) ShareShare
ReportReport
Posted on by 10

Hello,

I want to add a if condition on the 1:N entity. For example If a customer has 10 orders than place the separate <p> section if he/she has less that 10 orders than place the following <p> block in email template. I was actually struggling getting the number of rows. 
Can anyone help me with that ?

{{#if (gte contact.cra04_orders_contact_cra04_contactorders.Count 10)}}
<div class="col-md-12 col-lg-12 col-sm-12">
<p> It seems like that you haven't placed any order yet. If you are facing any issue than please do let us know. You can also click on the below link to report an issue. </p>
</div>

{{/if}}

Right now I am using this code but its wrong and not working. What is the right way to do that ?

Thanks,
Omer

I have the same question (0)
  • Verified answer
    Nya Profile Picture
    29,060 on at

    Hi Omer,

    The count cannot be used in the code block.

    It is recommended to create a custom field in Contact entity, which records the count of orders. You can set the Field Type of the field as Rollup.

     pastedimage1628501060421v1.png

    Edit its rule as the following screenshot.

     pastedimage1628501066394v2.png

    The default recurrence of the rollup calculation is 1 hour. You can change this with following steps:

    1. Navigating to Settings > System Jobs
    2. Select view "All Rollup Field Calculation Jobs"
    3. Select and Open the job with name "Calculate rollup fields for <your entity schema name> entity.
    4. In the job window, on the command bar, click Actions > Modify Recurrence.

     

    After creating the field, you can insert the code block into the marketing email.

    The code snippet is something like:

    {{#if (gte contact.new_countoforders 10)}} It seems like that you haven't placed any order yet. If you are facing any issue than please do let us know. You can also click on the below link to report an issue. {{else if (lt contact.new_countoforders 10)}} test {{/if}}

    And here is my test result.

    pastedimage1628501152069v3.pngpastedimage1628501186068v4.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 93 Super User 2025 Season 2

#2
TAHER_El_Mehdi Profile Picture

TAHER_El_Mehdi 30

#3
Satyam Prakash Profile Picture

Satyam Prakash 24

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans