Understanding Liquid markup and Zendesk Support

Return to top

47 Comments

  • Greg Katechis
    Zendesk Developer Advocacy

    Hi Tatiana! The reason you're seeing this error is because you used a single "=" sign...you'll need to use double "=" signs like this:

    {% if ticket.brand.name == "Brand A" %}

    This ticket is Brand A

    {% elsif ticket.brand.name == "Brand B" %}

    This ticket is Brand B

    {% else %}

    This ticket is one of our other brands

    {% endif %}
    0
  • Jacob the Moderator
    Community Moderator

    Hey Tatiana,

    Perhaps you could sidestep the issue by comparing part of the string (contains) without the apostrophe, as in...

    # string = 'hello world'
    {% if string contains 'hello' %}
    string includes 'hello'
    {% endif %}

    0
  • Jacob the Moderator
    Community Moderator

    Have you tried to wrap the string in single quotes rather than double?

    0
  • Walter

    HiGreg Katechis,

    Is it possible that the placeholders are not rendering inside of a logic tag?

    I tried a very simple liquid logic expression:

    {% assign my_variable = ticket.brand.name %}

    和分配的变量没有得到任何价值e.

    Therefore, I can safely assume that the following expression

    {% ifticket.brand.namecontains 'Jameson' %}

    will result in an error because it is the same thing as

    {% if NULL contains 'Jameson' %}

    0
  • Jacob the Moderator
    Community Moderator

    HiTatiana Ozaruk

    {% case ticket.brand.name %}
    {% when "BlueParro'th" %}
    This is brand with apostrophe
    {% when "Jabrah", "biscuit" %}
    This is NOT brand with apostrophe
    {% else %}
    This ticket is one of our other brands
    {% endcase %}

    Have you tried using case statements instead?

    0
  • Jacob the Moderator
    Community Moderator

    HiTatiana Ozaruk

    You probably resolved this a while back, I just came across the same error message, so I wanted to add my observations here.

    Placeholders have dots in them, and sometimes a composer window will interpret them as URLs, resulting in the error message "Liquid error: Unknown operator href=".

    When I un-linked the placeholder text and saved the macro, the error was no more and my Liquid Markup worked.

    0
  • Rawkers

    Hello,

    I wanted to know if there was a way to update a field to a certain value.
    It would be quite useful for me to update it with Liquid as I need to check another field to determine to which value the second field needs to be set to.

    Unfortunately, I could not find any information about such feature.
    Does anyone knows if it is possible or not?

    I thank you in advance and wish you all a nice day!

    0
  • Jacob the Moderator
    Community Moderator

    Hi Rawkers,

    Could you please give some more context, like what field type you would want to update and would you want to use placeholders from other fields?

    0
  • Rawkers

    Hello Jacob,

    Thanks for your quick answer!
    Both fields are multi-select.

    What I would like to do is to check the field A value and set field B to a value depending on A result. Basically, they are three choices for field B.


    (and field B could I guess be switched to a drop-down type field if that is more convenient for Liquid)

    0
  • Jacob the Moderator
    Community Moderator

    RawkersBoth multi-select and drop-downs use tags, so you can create triggers per value you want to set, like:

    Alternatively, you could use a trigger and webhook, and have liquid markup do the value checking for field A and setting field B based on that, but if the first option is a fit, I would go that route.

    1
  • Rawkers

    Hello Jacob,

    Thanks for your message.
    我不知道添加标签设置field to the corresponding value. I thought it was only the other way around so yup, I could setup everything using triggers and tags :)

    All sorted now, thanks again for your help!

    0
  • Michael Webb backup

    Hi,

    I'm currently attempting to assign to the ticket.tags placeholder corrected text for one of the tags via liquid implementation to webhook.

    {% assign cloned_tags = ticket.tags %}
    {% assign tags_without_text = cloned_tags | remove: ":clone" %}
    {% assign ticket_tags = tags_without_text%}
    {%assign ticket.tags=tags%}

    {{tags_without_text}}
    {{tags}}
    {{ticket.tags}}

    Barring the {{ticket.tags}} the other placeholders do correctly display all tags with all instances of :clone being removed thought it is the final one that I really want to change as that actually impacts the tickets

    I understand that I need to get this all in one line for a webhook but all of my attempts have been fruitless. Does anyone know how to format this in such way that it can be properly pushed to JSON, work and alter the {{ticket.tags}} placeholder

    0
  • Carmelo Rigatuso

    Hi,

    I'm having trouble with evaluating the value of a decimal field. No matter what I do, if I try to compare a value, it only evaluates on the first digit, so

    • 4, 40, 400, and 4000 are all greater than 3000.
    • 1, 10, 100, 100000 are all less than 3000.

    I've tried a couple of ways, doesn't matter:

    {% if {{ticket.ticket_field_123}} < '3000.00' %}
    {{ticket.ticket_field_123}} is less than $3000.
    {% endif %}

    {% if {{ticket.ticket_field_123}} > '3000.00' %}
    {{ticket.ticket_field_123}} is greater than $3000.
    {% endif %}

    {% assign totalvalue=”{{ticket.ticket_field_123}}" %}
    {% for totalanswer in totalvalue in %}
    {% if totalanswer > '3000' %}
    {{ totalanswer }} is greater than $3000.00.
    {% endif %}
    {% if totalanswer < '3000' %}
    {{ totalanswer }} is less than $3000.00.
    {% endif %}
    {% endfor %}

    both evaluate to > 3000 if my first digit is greater than 3.

    Why?!?! How do I get around this?!?!

    0
  • Walter

    HiCarmelo Rigatuso,

    It depends on what type of custom ticket fieldticket.ticket_field_123is.

    https://support.zendesk.com/hc/en-us/articles/4408838961562-About-custom-field-types

    0
  • Carmelo Rigatuso

    HiWalter,

    It's a decimal field, but I'm not sure what that has to do with comparison operations. 4 or 4.0 should never evaluate to greater than 3000.

    0
  • Walter

    Hi Carmelo,
    It looks like the number is being treated as a string.

    Try this instead.

    {% if {{ticket.ticket_field_123}} < 3000.00 %}
    {{ticket.ticket_field_123}} is less than $3000.
    {% endif %}

    0
  • Carmelo Rigatuso

    Walter

    When I try that, I get no errors when saving my trigger, but I get an error in the email notification:

    BUT!!! double-quotes fixes it!

    {% if {{ticket.ticket_field_123}} < "3000.00" %}
    {{ticket.ticket_field_123}} is LESS THAN $3000.
    {% endif %}

    {% if {{ticket.ticket_field_123}} > "3000.00" %}
    {{ticket.ticket_field_123}} is greater than $3000.
    {% endif %}

    Wow, that was a wild ride, thanks for the inspiration ;) I can't believe I didn't think of trying that yesterday.

    1

Pleasesign into leave a comment.

Powered by Zendesk