10.1: Add a required custom fieldset on ticket replies using automations #39
jstanden
started this conversation in
Guides and Tutorials
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introduction
In the Cerb 10.1 update, we added a mail.draft automation event for conditionally modifying the defaults on drafts when composing or replying.
In this guide we'll create an automation that adds a 'Classification' fieldset to every reply if the field isn't already set. We'll also require that the worker sets the custom field before sending.
Classification is a very common workflow where tickets are assigned a type, and reports can then visualize the breakdown of work being done. However, it's tedious for workers to remember to always add the fieldset.
We can use automations to make this workflow simpler.
Building the workflow
Creating a ticket classification fieldset
First, we'll need a custom fieldset for 'Classification' on tickets, with a 'Type' picklist of the kinds of tickets we receive.
We've prepared an example if you don't already have a fieldset for this. If you do, you can skip ahead to the next section.
Navigate to Setup >> Packages >> Import in Cerb.
Copy and paste the following package:
Click the Import button.
You should see the following:
Using the classification fieldset on ticket replies
Normally, workers would have to manually add our new fieldset on every reply:
cerb_10_1_mail_draft_manual_fieldset.mp4
Fortunately, we can now automate this.
Automating adding a custom fieldset when replying
Creating the mail.draft automation
Navigate to Search >> Automations >> (+).
wgm.example.draft.addFieldset
Add a custom fieldset to all new reply drafts
mail.draft
Paste the following Script:
Click the Save Changes button.
Binding the automation to the mail.draft event
Navigate to Search >> Automation Events and edit the mail.draft event.
Click the magnifying glass button in the toolbar above the event editor:
Select the wgm.example.draft.addFieldset automation we just created:
Click the blue Continue button.
This generates a binding on the event for the automation, like:
Let's customize the random name (
y26z3j
above) so it's more descriptive. We can also make the automation more efficient by only running it when the draft is new (and not resumed).Click the Save Changes button.
The automation will now run every time a new draft is created from the 'Reply' button, but only if the custom field isn't already set on the ticket.
Testing the automation
Navigate to Search >> Tickets and pick a ticket to reply to. Click on its subject to view its profile.
Click the Reply button on a message.
The custom fieldset is already enabled for us:
You can also set a proper default value (like "Question") in the automation. Any invalid value will default to the blank entry at the top of the list.
Requiring the custom field value
You may have noticed that even though we're defaulting the "Classification Type" custom field to enabled, we're not requiring that a value is selected before the message is sent.
We can optionally use another new feature in 10.1 for this -- a mail.draft.validate automation.
Navigate back to Search >> Automation Events and edit the mail.draft.validation event.
You may already have some automations bound to the event. Move the cursor to the bottom and click the magnifying glass button ("Find automation") in the toolbar:
This time we don't have an automation yet, so click the Create button above the list:
Enter the following field values:
wgm.example.draft.validate.ticketClassification
Require a ticket classification when replying
mail.draft.validate
Copy and paste the following KATA over the default
start:
Click the Save Changes button.
Select the new wgm.example.draft.validate.ticketClassification automation in the list and then click the blue Continue button.
This generates an automation event binding for us. We can finish it up like:
This will run the automation for ticket replies when there is no 'Classification' custom field set.
Conclusion
You now know how to conditionally modify the default settings of a draft.
You also know how to require a custom field in certain conditions.
Beta Was this translation helpful? Give feedback.
All reactions