Recent searches


No recent searches

Hide placeholders on emails that contain no data

Answered


Posted Feb 13, 2024

Hi

I am looking for a way to hide placeholders from being emailed/triggered that have no data.

For example, if I want to email all the following but Tel has no data in the field; is there a way to 'tag' the line so it is not sent if there is no data associated with it?

Requester: {{ticket.requester.name}}
Tel: {{ticket.requester.phone}}  (HIDE THIS WHOLE LINE IF THE FIELD HAS NO DATA)
Email: {{ticket.requester.email}}


0

5

5 comments

image avatar

Jakub

Zendesk Customer Care

Hello John Kenny

In Zendesk, you can use Liquid templating language to control the display of content based on conditions. To hide an entire line if a placeholder has no data, you can use an if statement to check if the placeholder has a value before displaying it.

Here's how you can modify your template to hide the telephone line if there is no phone number:


Requester: {{ticket.requester.name}}
{% if ticket.requester.phone != null %}
Tel: {{ticket.requester.phone}}
{% endif %}
Email: {{ticket.requester.email}}

I've tested and it works as expected, if there is no phone number, the "Tel" is also not shown. 

0


Hi Jakub

I cannot seem to get it working with custom fields.

In the example below. The New AU Mobile Number field is blank (no data in the database) and the New NZ Mobile has a number in the field, however, the New AU Mobile Number text is still displayed on the email. Example also below.

 

{% if ticket.ticket_field_1234589965327 != null %}
New AU Mobile Number: {{ticket.ticket_field_1234589965327}}
{% endif %}
{% if ticket.ticket_field_123455900431 != null %} 
New NZ Mobile Number: {{ticket.ticket_field_123455900431}} 
{% endif %}

Email text below.....

New AU Mobile Number:

New NZ Mobile Number: +64 21 345 234

0


Jakub

I appear to bet getting somewhere if I use != null and !=  "" like below.

However, when a line is not shown due to there being no data in the field, it leaves a blank line in it's place.

Would you know how I can make it so when a line is not shown, the space where it should be is also not displayed?

CODE:

{% if ticket.ticket_field_123456015119 != null and ticket.ticket_field_123456015119 != "" %}
Door Alarm Code Details: {{ticket.ticket_field_8812386015119}}
{% endif %}
{% if ticket.ticket_field_123455083151 != null and ticket.ticket_field_123455083151 != "" %}
Security Pass Details: {{ticket.ticket_field_123455083151}} 
{% endif %}
{% if ticket.ticket_field_123459965327 != null and ticket.ticket_field_123459965327 != "" %}
New AU Mobile Number: {{ticket.ticket_field_123459965327}}
{% endif %}
{% if ticket.ticket_field_123455900431 != null and ticket.ticket_field_123455900431 != "" %} 
New NZ Mobile Number: {{ticket.ticket_field_123455900431}} 
{% endif %}

 

Email example when New AU Mobile Number: is removed using Liquid Markup due to it having no data.........

Door Alarm Code Details: 54321

Security Pass Details: 12345

New NZ Mobile Number: +64 21 345 234

 

 

0


Figure it out. I need a hyphen in the endif. Example below:

 

{% if ticket.ticket_field_123456015119 != null and ticket.ticket_field_123456015119 != "" %}
Door Alarm Code Details: {{ticket.ticket_field_8812386015119}}
{% endif -%}
{% if ticket.ticket_field_123455083151 != null and ticket.ticket_field_123455083151 != "" %}
Security Pass Details: {{ticket.ticket_field_123455083151}} 
{% endif -%}
{% if ticket.ticket_field_123459965327 != null and ticket.ticket_field_123459965327 != "" %}
New AU Mobile Number: {{ticket.ticket_field_123459965327}}
{% endif -%}
{% if ticket.ticket_field_123455900431 != null and ticket.ticket_field_123455900431 != "" %} 
New NZ Mobile Number: {{ticket.ticket_field_123455900431}} 
{% endif -%}

0


image avatar

Brandon Tidd

Zendesk LuminaryUser Group LeaderThe Humblident Award - 2021Community Moderator

Great collaboration - and thanks for the follow up posts John Kenny!

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post