Notification

Mark Wood
Tera Contributor

Hello Team,

I want to implement the following requirement without using Flow Designer, as it is not available in the client environment:

  • Send the first notification to the approver 1 day after the approval record is created, if it is still not approved.

  • If the approval is still pending after that, send a second reminder after 24 hours.

  • If no action is taken, send a final reminder after another 24 hours.

  • If the approval is still not completed after all three notifications, then automatically close the RITM record.

Please guide me on how this can be achieved.

Thank you!

9 REPLIES 9

AndersBGS
Tera Patron
Tera Patron

Hi @Mark Wood ,

 

Why without Flow Designer - Flow designer is part of base when have a ServiceNow subscription.

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

SanjanaK
Tera Expert

1) Go to the Event Registry and create an event, let's say event name is "send.approval.notification". 
Create one more event for auto closing RITM, let's say event name is "auto.close.ritm".


2) As soon as the approval is created, you can schedule the events using below code in BR or your scripts:

var firstEventTime = new GlideDateTime();

var secondEventTime = new GlideDateTime();

var thirdEventTime = new GlideDateTime();

var autoCloseTime = new GlideDateTime();

 

firstEventTime.addSeconds(86400); // adding 24 hours to current time for the first notification

secondEventTime.addSeconds(172800); // adding 48 hours to current time for the second notification

thirdEventTime.addSeconds(259200); // adding 72 hours to current time for the third notification

autoCloseTime.addSeconds(345600); // adding 96 hours to current time for the third notification

 

//Now schedule an event
gs.eventQueueScheduled('send.approval.notification', table_object, '', '', firstEventTime);

gs.eventQueueScheduled('send.approval.notification', table_object, '', '', secondEventTime);

gs.eventQueueScheduled('send.approval.notification', table_object, '', '', thirdEventTime);

gs.eventQueueScheduled('auto.close.ritm', table_object, '', '', autoCloseTime); // auto close RITM on 4th day if not approved yet

 

3) Now create 3 notifications for first, second and third emails and add below 
When to Send:

Send when: Event is fired

Event name: send.approval.notification (Your event name)
Conditions: State is Requested

 

Who will Receive:

User/Groups in field: Approver

4) Now create an Script action on the trigger of 2nd event by mentioning it in event name as "auto.close.ritm"

Here you can write the code to check if the state is still requested then close the RITM.

*******************************************************************************************
Hope the answer helps!
Happy Learning!

Hello @SanjanaK,

Thank you for your input. However, I want to send the notification only when the approval state is "requested" and the approval is still pending. If the approver approves it after the first notification, then the second and third notifications should not be sent.

Please guide me on how this can be achieved.

Thank you.

Hey @Mark Wood ,

 

We have mentioned this check in the notification condition, so even if the second and third notifications are scheduled but they have the condition in 'When to send - if state is Requested'. 

So, when it's time to send the 2nd and 3rd notification, it will check if the state is still requested that means the approval is not yet received then only the notification will trigger, otherwise it won't send the second and third notifications.

 

Let us know if you are looking for something else.

*****************************************************************************
Hope the answer helps!
Happy Learning!