mistake | explanation |
Mixing old $or%%personalization>* within ESL | These variables do not mix. They are handled by two different services and the solution will either print the placeholders in the email or cancel the email. *Note: The legacy personalization placeholders are only available in the SAP Engagement Cloud | Emarsys edition. |
Using a single=instead of== | In general, you will only every use=for setting a variable and==to check a value or string. |
| Skipping a reference to the "global" object in JSON | If it some data is inside the “global” object, you must reference it in ESL.{{event.ordertotal}}instead of{{event.global.ordertotal}}is incorrect if inside of the "global" object |
| ESL/Twig is case sensitive | {{event.global.orderTotal}} is a different variable than {{event.global.ordertotal}} |
| With the exception of variables and values, you should exclusively use lowercase | Incorrect:{% if contact.1111 == 'Family' AND contact.2222 == 'Other' %}Incorrect: {% IF contact.1111 == 'Family' and contact.2222 == 'Other' %}Incorrect: {% if CONTACT.1111 == 'Family' and CONTACT.2222 == 'Other' %}Correct: {% if contact.1111 == 'Family' and contact.2222 == 'Other' %} |
| Inconsistent JSON structure | If you reference JSON via ESL without checking for the existence of it first, that variable must ALWAYS exist regardless of whether it is needed. If it is not in the JSON, that email will not be sent due to missing content. |
| Usually indicated by a large number of emails cancelled for "No Content" | |
| Calling an undefined variable | Just because another system may reference order by{{orders.lastorder.price}}, does not mean ESL will. With the exception of custom variables and variables inside of an array that you are looping, you are limited to using variables that start with the following:{{contact...}}{{event...}}{{rds...}} |
| Adding unnecessary spaces, extra words, or omitting spaces in statements | {% end foreach %} instead of{% endforeach %}{% else if %} instead of {% elseif %}{% end if %} instead of {% endif %}{% endelseif %} instead of {% endif %}{%if contact.1111 == 'Family'%} instead of {% if contact.1111 == 'Family' %}This will not necessarily break functionality, but it will break syntax highlighters and can cause confusion. |
Differences betweenif,elseif, andelse | In anifstatement, the only mandatory pieces are{% if foo == 'bar' %}and{% endif %}.elseifandelseare always optional but useful.ifis your opening condition. For everyif, there must be a closingendif. It can be nested inside anotherifbut both must eventually be closed.elseifis used exclusively for checking another condition after the previous one has failed. If you do not have a second condition to check, you should be usingelse.{% elseif %}is invalid. It should never be used without a precedingifand the precedingifmust not be already closed withendif.elseis your fallback. If none of the preceding conditions are true,elsewill be used instead. It is optional. If you do not want to set a fallback, you do not need to useelse. The natural behavior ofifis to not use a fallback. |
| Forgetting to use quotations when referencing a string | Strings are exact. In order to use them or check them, you must use single or double quotations surrounding them. |
| Using {{ and {% interchangeably | Incorrect:{{ endif }}Correct: {% endif %}Incorrect: {% contact.1111 %}Correct: {{contact.1111}}{{...}}should always be used to print variables from JSON, RDS, contact table, etc.{%...%} should always be used for statements or logic namely:{% if... {% foreach... {% set...When referencing a variable inside of a statement, you do not need {{…}}since you are not printing the variableCorrect: {% if contact.3 %}Incorrect: {% if {{contact.3}} %} |
Common mistakes
Was this article helpful?
1 out of 1 found this helpful