Recent searches


No recent searches

Turning nested field options into usable placeholders with dynamic content



image avatar

Dan Cooper

Community Moderator

Posted Apr 06, 2023

If you have nested drop down options, did you know you can create custom placeholders to tap into the text as specific levels in the hierarchy?If you have a value like Component::Sub Component::Sub Sub Component you can capture each section separately.

Create a new dynamic content item and add in the following.  You can customize the compcategory variable to whatever you want, and you'll need to update the ticket field id from 1234 to whatever your drop down field id is. 
{% assign compcategory = {{ticket.ticket_field_option_title_1234}} | split: "::" %} 

This splits your dropdown title into several options allowing you to create a custom variable based on the different category levels in your field option.  Now you can add the following options into your dynamic content as needed. 

{{ compcategory.first }} // will give you "Component"

{{ compcategory[1] }} // will give you "Sub Component" - if you have more than 3 sections, increment the number by 1 for each split

{{ compcategory.last }} // will give you "Sub Sub Component"
 
If you save your dynamic content variable, you'll get a placeholder like (the component_first will depend on what you named your dynamic content item. 
{{dc.component_first}}
Now you can use this new placeholder in triggers to create custom messages based on your deconstructed drop down value.

You can also use this on other field titles by swapping out what the split is looking for.  Maybe you use a hyphen in some option titles and you'd like to cut everything after the hyphen.  Change the split option from "::" to " - ". 

5

4

4 comments

Nice tip!

1


image avatar

Jennifer Rowe

Zendesk Documentation Team

This is great! Thanks for sharing this tip, Dan Cooper!

0


Hi all!

There may have been some changes to the platform that has made these instructions a bit different now than from when this was originally posted. If anyone has had any issues with this, I was able to follow these steps like this:

First, I named the Dynamic Content Object from the article but, I named it the same name as the field but with underscores to fill in any spaces. 

The field:

 

The Dynamic Content Object Name:

 

Then, I added the article's liquid markup with my ticket field's ID and, again, the name of the ticket field with underscores for the spaces. Lastly, I chose which of the categories/subcategories I wanted using the options laid out in the article. **Please note that which ever options you add here, all of them will show each time the placeholder is used. 

 

Finally, I added the resulting placeholder to my Macro. 

And tested it out in a test ticket. 

Hope this helps! 

1


For what it's worth I was playing with something similar for a multi-select dropdown, specifically wanting the “.last” item from multiple nested items. When only selecting one item it worked out, but when selecting multiple it would only display the last nested section of the last item overall instead of the last nest section from each selected item.

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post