Wix Answers Help Center
Adding Dynamic Text to Email Templates Based on Custom Ticket Fields
Create email templates with dynamic text that changes based on a ticket's custom field values. To do this, you need to create a custom LiquidJS code with an if/elsif/esle/endif clause, then add it to the relevant email template.
To add dynamic custom field text to an email template:
- Locate the System Generated Name of the relevant custom field. Learn how
- In the Wix Answers app, go to Settings > Tools > Email Templates.
- (Optional) Select a language next to Email Templates in.
- Click Edit next to the relevant template.
- Add the following text to the Email Subject or Email Body.
1
{%if ticket.customFields and ticket.customFields.<fieldname> %} {% if ticket.customFields.<fieldname> == "<value1>" %} ... {% elsif ticket.customFields.<fieldname> == "<value2>" %} ... {% else %} ... {% endif %} {% endif %}
- Replace <fieldname> with the System Generated Name you located in step 1.
For example: If the System Generated Name of the custom field you want to use is useros, you would replace <fieldname> with useros. - Replace <value1> and <value2> with the custom ticket values you want to use.
- Edit the LiquidJS operators in the script.
Show me the operators
9. Enter the text you would like to appear in the email template after each condition. For example:
1
{%if ticket.customFields and ticket.customFields.useros %} {% assign useros = ticket.customFields.useros %} {% if useros == "Windows" %} You are using Windows {% elsif useros == "Apple" %} You are using Apple {% else %} I am not sure what you are using {% endif %} {% endif %}
10. Click Save.
Was this article helpful?