How to use liquid in a trigger to convert {{ticket.tags}} to create a proper array?

1 Comments

  • Santiago Gandolfo
    Community Moderator
    Hi The Original DKNY!
    In our case we were faced with the same problem and just ended up sending the ticket.tags as a string to our backend and splitted it there. Is that a possibility for you?
    If not, I just tried a workaroud based on something else we did with another field, and it’s working for me (It is not the most beautiful thing)
    {% assign tags_array = ticket.tags | split: " " %}
    "ticket_tags": [
            {% if tags_array.size > 0 %}
                    {% for tag in tags_array %}		
                            {% if forloop.index < tags_array.size %}
                                    "{{tag}}",
                            {% else %}
                                    "{{tag}}"                                  
                            {% endif %}
                    {% endfor %}
            {% endif %}
    ]
    I don’t know if the {% if tags_array.size > 0 %} is really needed, could you try it and tell us if it worked for you?
    Cheers!
    0

Please sign in to leave a comment.

Powered by Zendesk