Pesquisas recentes


Sem pesquisas recentes

Embedding JSON inside Liquid IF Statement in Zendesk trigger for Webhook



Publicado 26 de abr. de 2024

The objective was to synchronize the "End user" field with an internal field with the same name for its field options. However, not all of the internal field's options can be made available to end users, so two separate fields were needed. While achieving this using multiple triggers is possible, it becomes cumbersome when there are more than 20 field options, as it would require creating 20 or more triggers for each option.

 

Create a trigger

in action notify webhook ( I used Update Manay API /api/v2/tickets/update_many.json)

and in JSON body use this code

{% if ticket.field_option_title_123456789 == "Option_A" %}
{"tickets": [{ "id": {{ticket.id}}, "additional_tags": "product_option_a"}]}
{% else %}
{% if ticket.field_option_title_123456789 == "Option_B" %}
{"tickets": [{ "id": {{ticket.id}}, "additional_tags": "product_option_b"}]}
{% else %}
{% if ticket.field_option_title_123456789 == "Option_C" %}
{"tickets": [{ "id": {{ticket.id}}, "additional_tags": "current_option_c"}]}
{% else %}
{% if ticket.field_option_title_123456789 == "Option_D" %}
{"tickets": [{ "id": {{ticket.id}}, "additional_tags": "product_option_d"}]}

{% endif %}{% endif %}{% endif %}{% endif %

 

In the above code, I am using an if statement to check if the field option title machines a text in “ ”

if true, I am passing JSON to the webhook 

Otherwise, it's moving to the next if statement.

Zendesk trigger will report this JSON as having an error, but it does not; you can ignore the error.

 


0

1

1 comentário

ashdivayus - did you have a question about the Liquid or is this meant to share what you've found with other users?  Looking at your code, I'm curious why you didn't use {% elsif %} ?

0


Por favor, entrar para comentar.

Não encontrou o que estava procurando?

Nova publicação