Question
How do I display multi-select field values as a bulleted list using triggers?
Answer
Use the Liquid split filter to divide this comma-separated list into an array, then display the items in that array in a bulleted list.
You can use the following Liquid statement in your trigger email body. Replace [field_id] with your desired field ID:
{% assign options = ticket.ticket_field_option_title_[field_id] | split: ", " %}
<ul>
{% for member in options %}
<li>{{ member }}</li>
{% endfor %}
</ul>
The code above sets a variable, options, to be the value of the multi-select ticket field. It then splits this variable at each comma, providing an array of options instead of just a single-line list.
In triggers, the line break is rendered in the email output and creates whitespace. When you implement this, place all the code on a single line.
{% assign options = ticket.ticket_field_option_title_[field_id] | split: ", " %}<ul>{% for member in options %}<li>{{ member }}</li>{% endfor %}</ul>
For more information, see Understanding Liquid markup and Zendesk Support.
4 Comments
Trying to get this working, but it seems to be failing on the placeholder. Even just putting the placeholder into an internal note on a ticket to test (like: {{ticket.ticket_field_option_title_360000224116}}) just displays blank, despite the milti-select field having values.
Is this the correct placeholder for a multi-select field?
Hey Scott,
I did some testing on my end and it looks like it's working for me:
Can you confirm you're using the correct ID for your ticket field?
I test by pasting manually into the comment as well as used a macro to apply the placeholder and both work.
Let me know!
Hey Brett,
Edit: Apologies I had a mistake in my tests. This works flawlessly, thanks for your article!
Thanks,
-SP
Hey Scott,
Thanks for the additional information and screenshots :)
As far as I can tell, everything is set up correctly on your end. I'm going to create a ticket on your behalf so our Customer Advocacy team can look into this for you.
This could possibly be a bug so they'll be able to assist further.
Cheers!
Please sign in to leave a comment.