Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

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

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

  • Verified answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: Get rows count from related record (1:N) in marketing email code block

    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans