rohan raj2
Tera Contributor

ServiceNow is doing great work in enabling enterprise digital transformation. To make sure that the work gets done 'the right way', approvals are required. In ServiceNow, we have the opportunity to not only digitize the approval process but also automate it. It's time to explore the process of configuring approval emails.

A case study approach to understanding approval notification in SN!

Let's say you have to configure an approval in a way that, when users place a request from the portal, their manager needs to approve at RITM level.

Here is the constraint, "you cannot alter the already configured workflows".

How will you go about it??

A notification can be triggered:

  1. By calling the notification itself (Using Server Side scripts)
  2. When an event is fired
  3. When a record is updated/ inserted in a table. (Most convenient)

We can use any of them, but for now, I will stick to option 2. It helps us get a better understanding of events, OOB scripts, notifications, and a bunch of important tables in SN.

But first, let's understand the end2end journey of approval!

find_real_file.png

 

So if you follow the steps given in the image, you should nail the approval email. But for our case, it isn't sufficient!

Why?

We are trying to get approval at RITM level, but the OOB 'Approval Events' script can only process 'request', sc tasks and standard change. It can't process RITM, so no event would be logged for RITM approval record. (We need an event to be logged so that a notification linked to that event will be triggered)

This small piece of code will do the magic! Add it in the Approval Events (Task) BR.

You will also need to plug a line of code to fire the event.

 // snippet starts here

function checkReqItem() {

var task = current.sysapproval.sys_class_name || current.source_table;

return (task == 'sc_req_item');

}

// spinnet ends here

If you haven't configured the event yet, you can simply go to 'System Policy > Event > Event Registry' and register a new event. You can name it 'ritm.approval.request' and use the same name in the Approval events BR to fire it.

Now link the event to the notification record. You can do this by going to the notification record, then setting the send when to 'event is fired' and add the event name as 'ritm.approval.request'.

Finally, configure the dynamic notification email, the way you want it!! Alternatively, you can also attach an email template here!

Now every time a user requests an item from Service Portal, their manager would get the approval request at RITM level. We achieved this without altering any workflow.

That's all. 

Before signing off, here is a table of elements discussed in the article.

#Name of elementTypeRemarks
1sysapproval_approverTableIt stores the approval generated from approval activity.
2Approval Events (Task)BRProcesses the records in the approval table and fires events
3sysevent_registerTableKeeps record of important events, which can be actioned upon (if need)

 

 

Happy learning.

Would love to improve this article with your suggestions!
Thanks!

Rohan Raj
Find me here: https://www.linkedin.com/in/rohanrajnow/

Comments
Harsha23
Tera Explorer

A little correction on the first point mentioned in the snippet - it is sysapproval_approver table, an underscore was placed by mistake, I think.

Version history
Last update:
‎08-22-2021 10:17 PM
Updated by: