Hey!
This post is about marketing emails design, html and each loops.
I am trying to figure out how to retrieve a field from a lookup field.
Code below explained:
{{#each contact.membership_id}} {{#if (this.main_membership_id.is_main_membership)}} //This is a lookup field on membership (1:N). I want to get the value of the bool is_main_membership. {{#if (ne this.statuscode 1)}} {{#if (ne this.reason_id.code 7)}} //Same as the first if statement. I want to reach the field on the lookup field. {{#if (ne this.reason_id.code 6)}} //Same as the row aboveEnd date: {{this.enddate}}
{{/if}} {{/if}} {{/if}} {{/if}} {{/each}}
Please help me understand if and how this is do-able!
Best regards,
Matilda
Thank you Nya for your answer! I will look into these documents further.
Just thought I should give you a better explanation of the data model (if it helps). This is how it was explained to me:
- A Contact can have several memberships (therefore we do a loop through them).
- A Membership is of a certain main_membership (like the type of the membership). this is where the bool is_main_membership is that we want to check against (one of the if statements).
- A Membership also has a reason for cancelation which is the 'reason' entity. We don't want any memberships with the reason of 'Deceased' for example which is one of the codes (we use codes because they are identical through all of our environments, but could use the unique identifier as well if that is easier).
Does this help anything? Or if there is any other info you need that can help you out, please don't hesitate to ask!
EDIT:
As written in you first link, this should work. So, I basically just need to find the correct entity reference names to make it work.
EDIT 2:
And how does the assist edit create or where does it get the relationships name? It is not the relationship names viewed on the tables in the solution. Or how is it built so that we can copy that syntax?
Best regards,
Matilda
Hi Matilda,
Since the entity you’re using is a custom one, the naming of the fields, the relationship to Contact, etc. are not clear.
Please refer to the following sections to know more about the expressions:
Expressions created by assist edit
Conditional statements and comparisons
And here is a tutorial about how to use code block and dynamic content with an N:1 (Contact: the other entity) relationship in marketing emails.
(+) Marketing Emails with custom code/Dynamics content - Marketing Community
You can adjust your code according to the above docs, or provide more info to me. For example, how the relationship between this entity and Contact is defined.
If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.
Best Regards,
Nya
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,817
Most Valuable Professional
nmaenpaa
101,156