Notification Script - add delay

Therese Tolenti
Tera Contributor

Is it possible to add a notification script via advance view. The script will be include adding a delay in sending the notification?

7 REPLIES 7

VikMach
Mega Sage

Hi @Therese,

If I understand you right you wish to add delay, so that notification triggers after a certain time.
There is Advanced condition to write the script. I see one OOB notifications which has something similar to your ask.
Notification is called "ConnectMessagePushNotification".
You could try something like that see if that works.

 

var liveProfileGR = new GlideRecord("live_profile");
liveProfileGR.addQuery("document", event.parm1);
liveProfileGR.query();
liveProfileGR.next()

var liveGroupMemberGR = new GlideRecord("live_group_member");
liveGroupMemberGR.addQuery("group", current.group);
liveGroupMemberGR.addQuery("member", liveProfileGR.getValue("sys_id"));
liveGroupMemberGR.query();
liveGroupMemberGR.next();

var messageTime = current.sys_created_on;
var last_viewed = liveGroupMemberGR.last_viewed;

answer = messageTime > last_viewed;



Let me know if that works!

Regards,
Vikas K

Ankur Bawiskar
Tera Patron
Tera Patron

@Therese Tolenti 

what's your actual business requirement here?

where you want to give delay?

From where and how are you triggering the notification?

If you are using gs.eventQueue() then you can use gs.eventQueueScheduled() and give delay

You can use after insert/update Business rule with script like this

 var gdt = new GlideDateTime();
 gdt.addSeconds(3600); // Add 1 hour
 gs.eventQueueScheduled("myEventName", gr, 'recipientEmailAddress', '', gdt);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Im also thinking of using event and BR. Sorry Im a newbie, Can i confirm what is gr?  and can i not add both param 1 and param 2?

gs.eventQueueScheduled("myEventName", gr, '', '', gdt);