{{ticket.requester.first_name}} issue

Answered

16 Comments

  • Amy Waugh

    If you want the name 'Mark' to appear from your ticket, use the following

    The ticket field has a unique number and this is what you need to use.

    e.g {{ticket.ticket_field_00000000}}

    (0's are the unique number)

    {{ticket.requester.first_name}} will always use the name that is assigned to that user, if it is always a specific person, then change their name to whoever will use it, (Enquiries to Mark)

    2
  • Carsten Falborg
    Community Moderator

    If you update the user in Zendesk with the right first and last name, you can use Zendesk's own {{ticket.requester.first_name}}. Other than that Amy is right.

    If you want to get creative you could do something with liquid markup and present your custom name field if present and if not use Zendesk's (should look something like this, but haven't tested it though):

    {% if ticket.ticket_field_00000000 != empty %}

    Dear {{ticket.ticket_field_00000000}}

    {% else %}

    Dear {{ticket.requester.first_name}}

    {% endif %}

    1
  • Michael

    I'm having a play with the logic and trying the following.

    {% if ticket.ticket_field_2993840 != empty %}

    Hi,

    {% else %}

    Dear {{ticket.ticket_field_2993840}}

    {% endif %}

    Can't seem to get it to work though - if ticket field is empty, show just Hi otherwise prefill with the ticket field from value 2993840 (the first name field).

    0
  • Graeme Carmichael
    Community Moderator

    Michael

    It looks like the condition is the wrong way round.

    % if ticket.ticket_field_2993840 == empty %}

    Hi,

    {% else %}

    Dear {{ticket.ticket_field_2993840}}

    {% endif %}

    0
  • Graeme Carmichael
    Community Moderator

    Michael

    Just remember that with this approach, custom fields start off empty until you first submit a ticket. The macro only reads the submitted ticket values.

    So, if you type a value into a blank custom field, then run a macro, the macro will still see the field as blank. Once you submit the ticket, the macro will see the custom field value.

    0
  • Michael

    Yer, tried that but was still having the same problem, seems the ticket name value had somehow got changed hence it wasn't pulling the data in correct from that specific field. Fixed and working now - thanks :)

    0
  • Michael

    I've been back and checked our macros and this now doesn't seemingly work.

    I have the following code:

    {% if ticket.ticket_field_29938409 == empty %}Hi,
    {% else %}Dear {{ticket.ticket_field_29938409}},
    {% endif %}

    Where 29938409 is the ticket field but presumably from the web form version. 

    Does the backend First Name field have a different value?

    0
  • Nikunj Vora

    Hi 

    We have a lot of customers with the first name = "Unknown". This happens because of our integration with Salesforce. 

    Will using the below work for us - 

    {% if ticket.requester.first_name == "Unknown" %}Hi,
    {% else %}Dear {{ticket.requester.first_name }},
    {% endif %}

     

    0
  • Michael

    We're not integrated with Salesforce and that unfortunately doesn't resolve the issue as the {{ticket.requester.first_name}} value then pulls inaccurate information based on the details in the email address.

    0
  • Shannon Anahata
    Zendesk Product Manager

    Hey Michael. I'd recommend double checking that field ID. The ID should be the same pulled from the form or your ticket field edit page in the admin panel. I noticed that your latest question is including a 9 at the end of your ID number, where in previous posts there wasn't one. If you continue to have problems getting this liquid to run properly after double checking the ID number, please open up a ticket with us so we can investigate your specific issue.

    0
  • Michael

    Thanks Shannon, i will open a ticket as on testing sometimes it works and some times it doesn't! Annoying!

    0
  • Blaine Knab

    Hi Michael,

    I'm updating you in the ticket as well, but I wanted to post here in case anyone else is trying to do something similar.

    The behavior you've run into is due to a slight difference between an "empty" field and a field with a null value.  If the field has never been filled in it will have a null value.  If it's had a value before but now is blank, it will be considered empty.  With this in mind you should be able to resolve this issue by adding an extra line to your code.  Try this instead:

    {% if ticket.ticket_field_29938409 == empty %}Hi,
    {% elsif ticket.ticket_field_29938409 == null %}Hi,
    {% else %}Dear {{ticket.ticket_field_29938409}},
    {% endif %}

    I hope this helps!

    0
  • McCabe Tonna
    Community Moderator

    We have an issue where many of our users are picked up as Text message users

    So i made this:

     

    {% case ticket.requester.first_name %}
    {% when 'Text' %}
    Hi,
    {% when 'text' %}
    Hi,
    {% else %}
    Hello {{ticket.requester.first_name}},
    {% endcase %}

    0
  • Martin Aalborg

    Hi guys, 

    I am trying to create a liquid expression, where if the first ticket field is not available, then it should take the name from a different ticket field. 

    However, the issue is that in the company we are using one macro for two slightly different ticket forms. I don't know if it is possible at all, but hopefully one can answer whether it is or if I should simply create a new macro. 

    Here is the code I've tried with, but unfortunately it only works in one of the ticket forms:

    {%-if ticket.ticket_field_360001992220 == ''360001992220'-%}

    Hi {{ticket.ticket_field_360001992220}},

    {%-elsif ticket.ticket_field_360001992220 != '360001992220'-%}

    Hi {{ticket.ticket_field_360002008939}},

    {%-endif-%}

     

    0
  • Dan Ross
    Community Moderator

    Hey Martin, 

    Not sure what you're trying to check with this. It currently looks like you're trying to see if custom field contains a specific number and if not, then use data in a different field for the greeting?

    There's a few potential syntax issues as well, try dropping the dashes before and after the % open/close brackets. You also have a double quote and a single quote on the ''360001992220'-%} part of the expression. Perhaps match all quotes with singles. It also looks like instead of checking if the field is filled, you're checking explicitly for that number.

    If I understand what you're trying to do ( not 100% sure I do) then something like this might help.

    {% if ticket.ticket_field_360001992220 != empty %}
    Hi, {{ticket.ticket_field_360001992220}},
    {% else %}
    Hi {{ticket.ticket_field_360002008939}},
    {% endif %}

    This tests if field 360001992220 is empty, and if it isn't, it'll use the value in that field. Otherwise, it'll use the value in the other field. You can add extra steps (like a test on the second field, before using it, if you'd like.

    Let us know!

    0
  • Martin Aalborg

    Hello Dan,

    Thanks for the reply. 

    You got it spot on, since it is working exactly as I want it to. 

    I am unfortunately not that profient in Liquid yet, so it is a bit confusing still. 

     

    Thank you very much for the help!

     

    Have a lovely day!

    0

Please sign in to leave a comment.

Powered by Zendesk