Update a parent ticket based on sub-ticket actions

In this article, you'll learn how to change things in a parent ticket base on actions taken in a sub-ticket. 

For example, let's say you wanted to post every comment that was made by an agent in a sub-ticket back to the parent ticket as a private comment.

There are 3 steps to make this happen.

Step 1: Create a target

Step 2: Get ID for "Parent Ticket ID"

Step 3: Create a trigger

 


 

Step 1: Creating the target

To create a target click on the admin cog on the left of the screen and right down the bottom go into extensions. Then click on "Add target" at the top right-hand side.

SweetHawk__-_Agent_7.png

Next, choose HTTP target

SweetHawk__-_Agent_8.png

 

Then give the target a name eg. "Update many" 

For the URL enter:

https://yourhelpdesk.zendesk.com/api/v2/tickets/update_many.json

Make sure you replace yourhelpdesk with your Zendesk URL ;-)

Set the method to "PUT, content type to "JSON", and lastly check to enable basic authentication and enter your Zendesk user credentials. 

The target should now look something like this:

SweetHawk__-_Agent.png

Finally, click submit to CREATE the target. 

 

Step 2: Get the ID for the parent ticket field.

In order to change the parent ticket, we'll need to reference the ID of it in the trigger. So, you'll need to search for it. You can do this by going to this URL:

https://yourhelpdesk.zendesk.com/api/v2/ticket_fields.json

(Replace yourhelpdesk with the name of your help desk)'

Then do a search (ctrl + f) for the "Parent Ticket ID" ticket field and make a note the ID like this: 

https___helpdemodesk_zendesk_com_api_v2_ticket_fields_json.png

You may see the information above displayed a little differently, but all you need is the ID so once you find it, make a note and head back to the agent interface. 

 

Step 3: Creating the trigger

Ok you're almost there. To create a trigger simply click on Triggers in your admin, and at the top right click on 'add trigger' like this:

SweetHawk__-_Agent_3.png

Then name your trigger something like "Update parent task"

Next under "Meet all of the following conditions" set the rules when you want the trigger to fire. For example, you may want it to only fire on tickets with an actual parent ticket, so you could add the rule:

"Parent Ticket ID" - "Present" 

You may only want to update the parent ticket when the sub-ticket is updated by the agent so you would add the rule:

"Current user" - "Is" - "Agent"

Finally based on the example we used at the start if you're wanting to update the parent ticket with a comment made on the sub-ticket, you'll probably want to check that one has actually been made with this rule:

"Comment" - "Is" - "Present (public or private)"

So your trigger rules might look something like this:

SweetHawk__-_Agent_4.png 

Finally under "ACTIONS" is where you set the rule to notify the target you created in step 1. 

You will need to add the rule:

 

"Notify target" - "Update many" 

 

Then the JSON body section is where you define what you want to happen. 

Since we'll be wanting to update the parent ticket we need to specify it by referencing the ticket field ID we collected in step 2. 

Your code might look something like this: 

{
  "tickets": [
    {
    "id": "{{ticket.ticket_field_81189308}}"
    }
  ]
}

Where 81189308 should be replaced with your ticket field ID. 

Once you've added in that code, you can start adding other rules to do stuff to the parent ticket. For example, if you wanted to change the status to open it would look like this: 

{
  "tickets": [
    {
    "id": "{{ticket.ticket_field_81189308}}",
    "status": "open"
    }
  ]
}

You can actually do anything you like to the parent ticket, and the full API documentation can be found on the Zendesk KB here: https://developer.zendesk.com/rest_api/docs/core/tickets 

For our example, we're wanting to post a private comment on the parent ticket of what was said on the sub-ticket, so the JSON will look like this:

{
  "tickets": [
    {
    "id": "{{ticket.ticket_field_81189308}}",
    "status": "open",
    "comment": { "body": "Comment from subticket: {{ticket.id}} - {{ticket.latest_comment}}", "public": false }
    }
  ]
}

SweetHawk__-_Agent_6.png

Once you're happy with what you're doing to the parent ticket, simply click to 'create' the trigger at the bottom right.

Sweet! You're now ready to test out your new workflow. 

Just create a ticket, then create a sub-ticket and do something to the sub-ticket which will match the conditions of the trigger above.

 

 

Have more questions? Submit a request

2 Comments

  • 1
    Avatar

    This has worked perfectly and absolutely improves our workflow. 

    Thank you Peter.

    Top Tip: When getting the ID in Step 2 if you use Firefox to browse to the URL instead of Chrome, it'll display in a more user-friendly format.

    Craig 

  • 0
    Avatar

    Thanks for the tip Craig! ... yes, I think for Chrome I had to install this plugin to make it look nice.

Please sign in to leave a comment.
Powered by Zendesk