Hi!
This issue regards HTML when designing a marketing email.
I am trying to get a startdate from an entity called "Membership" by using an #each loop.
I prefer c# but sometimes these tasks appear as well. What I would've done in c# is basically like this (code not tested):
DateTime startDate = new DateTime(); DateTime endDate = new DateTime(); foreach(var membership in memberships) { if(membership.startdate > startDate) { startDate = membership.startDate; endDate = membership.endDate; } }
var startDate = ?; var endDate = ?; {{#each contact.membership_id}} {{#if (gt this.startDate startDate)}} startDate = this.startDate; endDate = this.endDate; {{/if}} {{/each}}Member from:{startDate}
Member to:{endDate}
Please help me understand if and how this is do-able.
Another thought I had was to make a list with all the startdates and enddates (a list<datetime, datetime>-ish) and then choose the max datetime among all entries. But I have no clue on how to do this either.
Best regards,
Matilda
I have the same question, could we use variables en [tag:each] loop
Yeah, we thought of solutions including a new field, a parameter to the workflow or customer journey, but we are unfortunately not allowed to do any such changes.
I understood it the same way, that C# was not apply-able to the HTML. But there are no other ways in HTML to use variables or lists the way I want then? If not then I will just have to accept defeat.
Thank you for the fast answer!
Best regards,
Matilda
Hi Matilda,
The C# code is not supported in the code block of Marketing Emails.
It is recommended to create a custom field in your entity, which can record the latest date with something like workflow. Then insert the field as a dynamic content into the email, so that the latest date can be shown.
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156