10.0: Conditionally approve and deny record merges with automation events #14
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
Let's assume you only want to allow ticket records to be merged when they all share the same list of participants. In any other case you want to prevent the merge.
Cerb has a 'Ticket merge' permission in roles, but this just allows or denies the merge feature. It doesn't allow for custom business logic.
As of Cerb 10.0 you can implement this logic using the record.merge automation event.
In this guide we'll walk through setting this up.
Create an automation
First, we need an automation to implement our business logic.
Navigate to Search -> Automations -> (+).
wgm.merge.ticket.onlySameParticipants
Only allow tickets to be merged if they share the same participants
Paste the following automation into the script editor:
You can test the automation by pasting this input into the Input: window:
You can modify the IDs to meet your use case.
The
__expandable
key is a hint to the dictionary that those paths are sub-dictionaries. That means you can expand a placeholder likerecords[1].participants
without doing any extra work. This is what happens with continuations.When an automation event triggers outside of the simulator all of this is done for you.
You can also simulate participants in your test data (without key expansion) like:
When you're satisfied with your test input, click the run button:
If you picked tickets with different participants, you'll see output like:
This would deny the merge.
If you choose tickets with the same participants (or you fake the participants in the simulator), you'll see:
This would allow the merge.
You can test this as much as you want since the automation doesn't change any data. It simply returns a
__return:deny:
key, or not, to whatever functionality invokes the automation.Configure the automation event
Now that we have an automation that meets our needs, we can configure it on the event.
Navigate to Search -> Automation Events.
Edit the
record.merge
event.Paste the following KATA into the event editor:
This runs our
record.merge
automation only when the records being merged are tickets.Click the Save Changes button.
Testing the event
Creating test data
You may want to create some test data at this point if you're on a production system.
Navigate to Setup -> Mail -> Incoming -> Import.
Paste the following message:
Click the Import button to create a ticket.
Repeat the above steps to create a duplicate message. We'll end up merging those tickets.
Now create a ticket from a different sender:
Click the Import button.
You now have three test tickets.
Merging with your custom logic
Navigate to Search -> Tickets. If you need to reset the results, run the query:
sort:-updated
Select the message from
[email protected]
and one of the messages from[email protected]
and click the merge button below the worklist.Click Continue twice.
You should see an error:
Now select the two messages from [email protected] and click the merge button below the worklist.
Click Continue twice.
You should see a success message:
You now have full control over record merging logic.
Beta Was this translation helpful? Give feedback.
All reactions