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:
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.
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:
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.
38 Comments