Automatic ticket creation for task list item (beta)

Also see: Duplicating conversations & attachments into child tickets

 

To have a task automatically create a ticket when it's added to the ticket, first you will need to turn this feature on by clicking on the tasks admin icon on the left of the screen. Then switch it on under 'settings' like this:

SweetHawk__-_Agent.png

Important: please click Save settings to commit any changed settings.

Next... to define the details of the ticket you want to create, under the 'Task lists' tab, go into the desired list, then click the 'edit' button next to the task you want.

SweetHawk__-_Agent_2.png

Finally, in the popup screen, in the 'ticket data' section, you will need to provide some JSON that defines the details of the ticket to be created like this:

SweetHawk__-_Agent_3.png

To have a ticket automatically created, you can start by defining a minimal JSON structure in the Ticket data field:

{}

This will create a ticket with default values: the subject will be set to the task list item's name, the description will be just '.' and created as Internal Note.

If you'd like to set other fields, this can be done like this:

{
  "subject": "Printer fire",
  "priority": "high",
  "comment": {
    "body": "Some smoke is coming out!",
    "public": true
  }
}

You can use liquid markup inside the values to copy values from the parent ticket:

{
  "requester_id": "{{ticket.requester.id}}",
  "comment": {
    "body": "Get back to {{ticket.requester.email}} regarding {{ticket.subject}}",
    "public": false
  }
}

You can set custom fields like this:

{
  "subject": "Printer fire",
  "custom_fields": [
    { "id": 12345678, "value": "custom_field_value" },
    { "id": 12345679, "value": "Here's a value" },
    { "id": 12345680, "value": "{{ticket.ticket_field_12345680}}" }
  ]
}

Or set the form and subject to match the parent ticket like this: 

{
  "subject": "{{ticket.title}}",
  "ticket_form_id": "{{ticket.ticket_form_id}}"
}

Because the JSON used is identical to the format Zendesk uses to create tickets, more information about the fields you can use can be found in Zendesk's API documentation.

 

Have more questions? Submit a request

7 Comments

  • 0
    Avatar

    How i can create newline in comments body?

    something like: "body": "Get back to {{ticket.requester.email}} <br/> regarding {{ticket.subject}}"

     

  • 0
    Avatar

    For newlines, please use "\n" (backslash N) so in your example: "body": "Get back to {{ticket.requester.email}}\nregarding {{ticket.subject}}"

  • 0
    Avatar
    Thomas D'Hoe

    Is it also possible to take the attachments of the parent ticket over in the child tickets?

     

  • 0
    Avatar

    Hi Thomas, currently it isn't possible to replicate the attachments over in the children tickets. I think the key thing to for us to get right if we were able to build this functionality is being able to specify attachments to be copied since often there are many superfluous attachments that are just noise. Copying all of those attachments to many tickets would simply amplify the noise. 

  • 0
    Avatar

    Can you leave comments in the code? I have several fields I am putting in with custom data fields and I would like to note which custom field is on each line. Is there a leading character that indicates comments like -- or // ?

  • 0
    Avatar

    Hi George, you can't technically use comments in JSON but you can use this trick to add meta information for your own purposes:

    {
      "custom_fields": [
        { "id": 12345680, "value": "{{ticket.ticket_field_12345680}}", "field_name": "My custom date field" }
      ]
    }

    By using another node like "field_name" you can effectively add comments, as any JSON fields other than the documented ones will be preserved but ignored.

  • 0
    Avatar

    @Thomas - regarding copying attachments from the parent ticket into the child. We've made a couple of changes to make this possible now. If you just want to copy the attachments you can use this code: 

    {
      "comment": {
        "html_body": "{% for comment in ticket.public_comments %}<b>{% for attachment in comment.attachments %}<a href='{{attachment.url}}'>{{attachment.filename}}</a></br>{% endfor %}</br>{% endfor %}",
        "public": true
      }
    }

    If you want to copy the entire conversation of the parent ticket including attachments you can use this code: 

    {
      "comment": {
        "html_body": "{% for comment in ticket.public_comments %}<hr><b>{{comment.author.name}}</b> - {{comment.created_at_with_time}}</br></br>{{comment.value_rich}}{% for attachment in comment.attachments %}<a href='{{attachment.url}}'>{{attachment.filename}}</a></br>{% endfor %}</br>{% endfor %}",
        "public": true
      }
    }

Please sign in to leave a comment.
Powered by Zendesk