Dear Community,
I have been trying to implement conditional statement but it doesn't work for me.
Can you suggest what's wrong?
Original method
<% if ( toString(rtEvent.ctx.@freeText22).length > 0 ) { %>
<tr>
<td class="mpbx-27" style="font-size:16px; line-height:22px; font-family:'Core Sans C', Helvetica, Arial, sans-serif; font-weight: 400; text-align:left; min-width:auto !important; color:#151515; padding-bottom: 20px;">
<strong>Sources</strong><br />
<%= rtEvent.ctx.@freeText22 %>
</td>
</tr>
<% } %>
New method
<% var ctx = XML(rtEvent.ctx); %>
<% if ( rtEvent.ctx.@freeText22 == true ) { %>
<tr>
<td class="mpbx-27" style="font-size:16px; line-height:22px; font-family:'Core Sans C', Helvetica, Arial, sans-serif; font-weight: 400; text-align:left; min-width:auto !important; color:#151515; padding-bottom: 20px;">
<strong>Sources</strong><br />
<%= rtEvent.ctx.@freeText22 %>
</td>
</tr>
<% } %>
<%} else { %>
<%}%>
Thanks!!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @AkshayAnand
Finally, it works!!!
trim is the missing keyword!
Thanks for your support!
Cheers
Snehil
Hi @srvphoenix
If you want to do a comparison to a string "TRUE", then please insert the string in single inverted commas and try.
If you want to give a boolean check of true or false, then you can use numerical values 0(false) 1 or any positive value (true) to check the if block.
Eg :-
if (abc == 'true') --> string comparison
if (abc = 1 ) --> check for true condition
if (abc = 0) --> check for false condition
Also Could you please check the brackets, I can see an extra closing bracket in the above code.
Regards
Akshay
Hi Akshay,
Thanks for your input.
I tried again your suggestions but no matter what I put in the if else condition, I always get the else statement (even with negation). I tried =="true" with and without quotes, boolean logic, ! to get inversion, NULL but none work with Transactional emails.
Do you have a working sample along with a payload that you can show?
Thanks again!
Snehil Singh
Views
Replies
Total Likes
Hi @srvphoenix
Please find the working code at our end.
Another example
Also could you please try rtEvent.ctx.freeText22 == 'true' once as the dot location for new parent field is .field and for child elements inside the field is .field@childElement
Please let me know if it works.
Regards
Akshay
Hi @AkshayAnand
Finally, it works!!!
trim is the missing keyword!
Thanks for your support!
Cheers
Snehil
Views
Likes
Replies
Views
Likes
Replies