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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

ForEach loop is not working in dynamic content Marketing email

(0) ShareShare
ReportReport
Posted on by 216

Hi Everyone.

I am trying to retrieve all activities with their Due Date against the contact by using custome code in marketing email design.But it is not working im getting the following eeror, if anybody knows what im missing

6136.error.PNG

error2.png

Thanks

I have the same question (0)
  • Verified answer
    cloflyMao Profile Picture
    25,210 on at

    Hi Fariha,

    Comment(<!-- -->) is not required to code.

    Your activities below:

      {{#each contact.activitypointer_contact_regardingobjectid}}
    • Activity Name: {{this.subject}} Due Date: {{this.scheduledend}}
    • {{/each}}

    pastedimage1573091093167v1.png

    In addition, I would like to share some experiences for dynamic expression:

    1. DE could only support to retrieve entities that have direct relationship to contact, 

    in other word, we could only use relationships in assist-edit drop down list.

    2. Some fields type such as:

    Lookup: it will display related entity's record id instead of its name. 

    Date and time: it will display both date and time.(as in my screenshots).

    -> You need a workflow to sync data from original field to custom field and convert data to formatted value.

    Currency: it will only display number without symbol.

    -> You should add symbol manually in HTML.

    Regards,

    Clofly

  • Fariha Asmat Profile Picture
    216 on at

    Thanks Clofy,

    But can we apply the condition on which i can get those activities in email whose due date is " today " ?

  • Fariha Asmat Profile Picture
    216 on at

    How we can apply If else condition on Date type field.?

  • cloflyMao Profile Picture
    25,210 on at

    Hi Fariha,

    Ae per my understanding, we might couldn't compare date type.

    From listed operators in the doc, it seems that only number and string type are supported to condition check, while javascript is blocked on marketing email.

    Regards,

    Clofly

  • cloflyMao Profile Picture
    25,210 on at

    Hi Fariha,

    You might still need cutom field to save remaining days with scheduled workflow.

    Regards,

    Clofly

  • Roger Comley Profile Picture
    15 on at

    Hi Clofly,

    I can't get my for each loop to work, it keeps giving me the error as the opening poster gets.

    My piece of code:

    {{#each contact.sbb_contact_msevtmgt_event_applicantid}}

    {{this.sbb_adviserpracticallearningname}}

    {{/each}}

    Above code resolves in error, I'm sure this must be right? The relationship is a 1:N relationship from Contact -> Event.

    The code I want in the end must also include a if statement:

    {{#each contact.sbb_contact_msevtmgt_event_applicantid}}

    {{#if (eq this.sbb_eventnumber 01108)}}

    {{this.sbb_adviserpracticallearningname}}

    {{/if}}

    {{/each}}

  • Oseirf Profile Picture
    67 on at

    Hi  Roger Comley

    I'm struggeling at the moment in the same way - where you able to solve this each-clause? 

    Kind Regards

    Frieso

  • cloflyMao Profile Picture
    25,210 on at

    Hi Roger,

    Could you open a new thread for your problem? Thanks.

    Regards,

    Clofly

  • Roger Comley Profile Picture
    15 on at

    Yes, to get the correct relationship technical names you should create a segment and look in the Query part, the relationship names in the CRM and marketing insights database are different(!)

  • Oseirf Profile Picture
    67 on at

    great thanks a lot :) it works :)

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 73 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans