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",
  "tags": ["printer", "fire", "smoke"],

  "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}}",
"assignee_id": "{{ticket.assignee.id}}",
"group_id": "{{ticket.group.id}}",
"brand_id": "{{ticket.brand.id}}",
"ticket_form_id": "{{ticket.ticket_form_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}}" }
  ]
}

Please note that multi-select fields cannot be set by value because of the JSON representation. The correct JSON can be generated using the following code:

{
  "custom_fields": [
    { "id": 123, "value": [{% for value in ticket.ticket_field_123 %}"{{value}}"{% if forloop.last == false %},{% endif %}{% endfor %}] }
  ]
}

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

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

Should you wish to copy tags from the parent ticket, please use the code below:

{
  "tags": [{% for value in ticket.tags %}"{{value}}"{% if forloop.last == false %},{% endif %}{% endfor %}]
}

If you want to combine setting specific tags and copying the parent ticket tags as well, you can modify the code like this:

{
  "tags": ["my_custom_tag", {% for value in ticket.tags %}"{{value}}"{% if forloop.last == false %},{% endif %}{% endfor %}]
}

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
  }
}

Alternatively, if you want to copy ONLY the attachments you could 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
  }
}

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

38 Comments

  • 0
    Avatar

    Hi.

    I'm having an issue where when a comment is left on a closed ticket and it automatically opens a new ticket, the new ticket is created with a new set of sub tickets automatically generated via the follow-up to a closed ticket. This continues to happen with every reply to that closed ticket. Is there a way to stop the automatic addition of a task list for follow-up tickets? 

    Irving

     

     

  • 0
    Avatar

    Hi Irving, yes this is possible. Since Zendesk triggers are what add task lists to tickets, you can set the conditions for when each trigger fires to exclude certain types of tickets. For example, if you don't what them firing on follow up tickets you could add the rule "channel" - "is not" - "closed ticket" like this:

    However, there are other ways to address this also. Since a closed ticket retains the tags of the original ticket, you could set the task list to tag the ticket at the point it's added to the original ticket. Then you could add a condition to the trigger checking for the absence of that tag.

  • 0
    Avatar

    Hi Peter

    If a Calendar event (by Sweethawk Calendar App)  is in the Parent ticket can that be linked to the sub ticket which is created through the tasks list?

    Also, Is it possible to delay the creation of the sub-ticket until the previous task has been completed?

    Thanks

    Rowland

  • 0
    Avatar

    Hi,

    Is there a way, within the script, to only pull the latest comments?

    Thanks,

    Chee

  • 0
    Avatar

    Hi Rowland, 

    Thanks for posting. A calendar event can only be attached to the ticket it exists on. So while it can not be also linked to a child ticket, you could potentially copy the event details from the parent ticket to the child ticket. This would mean you then have 2 events for the same thing. So you could either use the task list tagging feature to automatically delete the event from the parent ticket the instant the child ticket is created OR you could consider copying the event to a different calendar which might work in use cases where one calendar is for proposing an event and the other calendar is for events that have been locked in. 

    Regarding your other question. The only way to delay the creation of a sub-ticket until the previous task is completed would be to separate out the sub-ticket task into its own task list. Then you could specify a tag to be added at the point the preceding task was completed (as defined here) and based on that tag, a trigger could be setup to automatically add the list containing the single task. We have a vid on how to auto add task lists to tickets here

  • 0
    Avatar

    Hi Chee, Yes you can pull just the latest comment into the description of a sub-ticket with the following code: 

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

    If you want to only post the latest public comment you could use {{ticket.latest_public_comment.value_rich}} instead. 

  • 0
    Avatar

    When creating the child tickets automatically via Tasks, is it possible to set the ticket form? At present, any sub ticket created is using our ticket form that is set as default.

  • 0
    Avatar

    This beta has now ended and we no longer accept new opt ins.

    We are in the process of introducing Ticket Templates to replace this functionality, but those customers who opted into this feature will be continued to be supported as the new ticket template functionality is backwards compatible.

    Please contact us to opt into ticket templates at short notice but we'll also gradually roll this feature out to all customers over the next few weeks.

Please sign in to leave a comment.
Powered by Zendesk