Search code examples
shopifyliquidtargetzendeskzendesk-api

How to skip \ sign in liquid code?


I am creating a JSON (Transfer a ticket content to another ticket) for a HTTP Target:

{
  "ticket": {
    "subject":"{{ticket.title}}",
    "description":"{{ticket.description}}",
    "type":"{{ticket.ticket_type}}",
    "priority": "{{ticket.priority}}",
    "tags":"{{ticket.tags}}",
    "status": "{{ticket.status}}",
    "comment":"{{ticket.comments_formatted}}",
    "requester": { "name": "{{ticket.requester.name}}", "email": "{{ticket.requester.email}}" },
    "collaborators": ["{% capture emails %}{% for cc in ticket.ccs %}{% unless forloop.last %}{{ cc.email | append: '\", \"' }}{% else %}{{ cc.email }}{% endunless %}{% endfor %}{% endcapture %}{{ emails | strip_newlines | replace: '\\', ''}}"]
}

However, the collaborators does not work. The correct format should be

My code's output is:

I am wondering that how to skip the \ sign?

Thanks!


Solution

  • I have solved this issue, I want to post my solution here:

    1. Create a Dynamic Content in Zendesk:"{% capture emails %}{% for cc in ticket.ccs %}{% unless forloop.last %}{{ cc.email | append: '", "' }}{% else %}{{ cc.email }}{% endunless %}{% endfor %}{% endcapture %}{{ emails | strip_newlines }}"
    2. In the trigger JSON, use: "collaborators":"{{dc_ccs}}"

    This can transfer all CCs from the old ticket to the new ticket.