|
This article is regarding the Approvals app. |
When creating a manual approval template you will need to define the ticket conditions for when an approval is required (aka visible) on a ticket.
When these conditions are met, the approval(s) will appear on the right like this:
If you're on a Zendesk plan that has "forms", then you can choose the form as the condition from within the template. However, if you don't have forms, or you just want to set more complex conditions on a ticket then clicking the option like this...
...will display a text box where you can create your own JSON code conditions for ticket fields.
For example, you may require finance approval for international travel requests. So to make the approval required on those tickets, we create a rule that looks like this:
[{"custom_field_44974587":["travel_international"]}]
And place it into the box like this:
In the code above it's saying, if the 'Travel Type' field = international, then the approval will be required and will show in the apps pane.
The way that we're identifying the 'Travel Type' ticket field is with "custom_field_44974587". The number you see on the right (44974587) is the ticket field ID, which can be copied from any custom field by going to Admin -> Ticket Fields and then clicking on the ticket field in question. You'll see the ID at the top like this:
The bit that says "travel_international" is referring to the tag that's associated with the dropdown field selection. So you'll be able to copy the tag from the field selection like this:
You're also able to setup multiple field conditions, for example, if I wanted to only show the approval for international flights where the reason for travel was "other" I could write something like this:
[{"custom_field_43729647":["travel_other"],"custom_field_44974587":["travel_international"]}]
As you can see, simply by separating the rules with a comma, you're able to create as many conditions as required.
Checkbox fields
Checkbox fields are a little different than dropdowns menus because if you specify the tag associated with them in the rule, they don't react instantly.
As such it's better to specify checkboxes with "yes" or "no".
So if checkbox "Approval required" must be checked before the approval is shown, then your rule will look like this:
[{"custom_field_47017668":["yes"]}]
Alternatively, if you only want the approval to show if the checkbox is not ticked, then your rule will look like this:
[{"custom_field_47017668":["no"]}]
Note: If you're having trouble writing the rules, email us at support@sweethawk.co and we'll help write the conditions for you.
You're also able to specify conditions other than custom fields, like the ticket type, or the form. These are a bit different than just regular custom ticket fields as you won't be able to just navigate to the field to find the ID, like we've shown above. For standard ticket fields like 'ticket-type' and 'priority' you can just refer to the names in the fields like this:
[{"type":["question"]}]
or
[{"priority":["high"]}]
If you're needing to create a condition based on the ticket form, that's different again. First, we'll need to dig out the form id by going to this URL:
https://yourhelpdesk.zendesk.com/api/v2/ticket_forms.json
(replace "yourhelpdesk" with the name of your help desk)
Search for the desired form and copy the id like this:
And your rule would look like this:
[{"form.id":[421508]}]
If I wanted to use all 3 of this conditions together, I could write them in the same rule, simply by separating them with a comma like this:
[{"type":["question"],"form.id":[421508],"priority":["high"]}]
Reference
At the highest level, specify your OR conditions. The JSON is an array of conditions of which any of them should be met. If you'd like your ticket to meet any one of the conditions A or B, write this in the format [A, B]. Example:
[{"type": ["question"]}, {"priority": ["low"]}]
The statement above translates to {"type": ["question"]} OR {"priority": ["low"]} so the ticket should either be of type Question or has Low priority.
The next level down is a series of AND conditions. All of them should be met for the condition to be valid. So if you need condition X and Y to both be true, write: [{X, Y}]. Example:
[{"type": ["question"], "priority": ["low"]}]
In the example, the ticket must be both of type Question and Low priority.
After the field name, you must enter an array of values where any of them must be valid. This will allow you to save typing lots of complicated conditions when you want to allow multiple values for a field. So if you'd like field F to have value D or E, write: [{F: [D, E]}]. Example:
[{"priority": ["low", "normal"]}]
This condition means the ticket should have either Low or Normal priority.
You can combine as many OR conditions and AND conditions to achieve your desired ticket condition. So if you want either X and Y to be met or A, then write: [{X, Y}, A]. When you have a lot of conditions, it can be desirable to add newlines and indentation to ensure you have all conditions in the correct place and the logic adds up:
[
{
"priority": ["normal", "high"],
"type": ["question", "task"]
}, {
"priority": ["low", "normal", "high"],
"type": ["problem", "incident"]
},
{
"priority": ["urgent"]
}
]
Troubleshooting
If your approval isn't showing in the apps pane and it should, here are some things you can try:
- Try refreshing your browser.
- You might be getting a bit complex with your rule. Perhaps start with a super simple one first, just to test that it's working; For example, if the ticket type is question... [{"type":["question"]}]
- Check the quotation marks. Unbeknown to most, there are two types of double quotation marks and it's really difficult to tell the difference between the two. They look like this:
"
and this:“
I know it's hard to see, so let's see them a bit bigger:
There's the curly type and the straight type.
They need to be the straight type to work in JSON. You should be right copying the code from this article, but we thought we'd make a note of it here in the off chance you're copying from Word or Text-edit which automatically converts quotes into curly ones :-/