Skip to main content

Notifications

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

  • slx Profile Picture
    slx 386 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    Could we add datetime in a condition ?

    <!-- #if (gt this.createdon '2023-01-01') -->

    ?

    thank you

  • JacquesNL Profile Picture
    JacquesNL 800 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    Good Morning,

    Just 1 sec ago I figured out that I was referencing the wrong field. So indeed, wrong logical name!

    Thank you for the quick response!

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    Hi Jacques,

    Is "rbc_buildingcity" the correct logical name of your custom field of Event entity?

    Regards,

    Clofly

  • JacquesNL Profile Picture
    JacquesNL 800 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    Hi, can you explain to me what you did to make it work? I still get the following error:

    Text: Dynamic content contains an invalid relationship or property: {{this.rbc_buildingcity}}
    HTML: Dynamic content contains an invalid relationship or property: {{this.rbc_buildingcity}}

    My for-each:
    {{#each contact.msevtmgt_eventregistration_contact_msevtmgt_contactid}}

    {{this.rbc_buildingcity}}

    {{/each}}

    I build the for-each using the assist, but you used the query builder in the segment? 

    Thank you in advance!


    Br,

    Jacques

  • Oseirf Profile Picture
    Oseirf 67 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    great thanks a lot :) it works :)

  • Roger Comley Profile Picture
    Roger Comley 15 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    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(!)

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    Hi Roger,

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

    Regards,

    Clofly

  • Oseirf Profile Picture
    Oseirf 67 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    Hi  Roger Comley

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

    Kind Regards

    Frieso

  • Roger Comley Profile Picture
    Roger Comley 15 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    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}}

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: ForEach loop is not working in dynamic content Marketing email

    Hi Fariha,

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

    Regards,

    Clofly

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans