loopsliquidzendeskzendesk-api

Dynamically pass +1 count to a ticket field in zendesk using Liquid


I have a text field in zendesk. I want to pass a +1 count to this field each time the ticket is updated. This needs to be done via liquid. For example if the field is blank and ticket is updated then the trigger will pass 1 to this field and if the field contains the value 5 and the ticket is updated again then the value will be updated and will become 6. I am not having very good experience with liquid. Please let me know if there is any way to do it.


Solution

  • I was able to do this after some research. I have updated the field using trigger and used http target. Here is what I did and it is successfully working:

     {% assign escalation_count = 0 %}
     {% if ticket.ticket_field_[FieldId] == empty %}
       {% assign escalation_count = 1 %}
     {% else %}
       {% assign escalation_count = {{ticket.ticket_field_[FieldId]}} %}
       {% assign escalation_count = escalation_count | plus: 1 %}
     {% endif %}
     { "ticket":{ "custom_fields":[{"id":[FIELD ID],"value":"{{escalation_count}}"}]} }