How to send notification based on time interval

Nag9
Tera Expert

In my req

I want to send notifications to the owner of the story, if state changes to UAT and testing will not happen upto 2 days.

So need to set reminder for the story owner after 48 hours , still story testing pending 

I created event and business rule but its not wrking

 

Can anyone help me out on this

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi Nag,

Instead of BR, try scheduled job. Because with BR, once the event is scheduled, it will trigger event irrespective of update happened later or not. Since you want to send notif only if there is no update in 2 days after state changes to UAT, it is better to try with scheduled script.

var gr = new GlideRecord("rm_story");
gr.addEncodedQuery("sys_updated_on<javascript:gs.beginningOfYesterday()^state=1"); //place value of UAT here
gr.query();
while(gr.next())
{
gs.eventQueue('your_event_name',gr,gs.getUserName(),gs.getUserID()); 
}

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP

View solution in original post

18 REPLIES 18

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So when state changes to UAT you can trigger using eventScheduled()

BR: After update State changes to UAT

Script below:

Ensure you use proper owner field

this will send the event exact 48hours after state changes to UAT

var newDateTime = new GlideDateTime(date);
newDateTime.addDaysUTC(2);

gs.eventQueueScheduled("event_name", current, current.owner, current.owner.getDisplayValue(), newDateTime);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi Ankur

Im trying same code, can you help how to make time for 5 mins for testing purpose

Hi,

for testing purpose you can give 5mins as below

addSeconds(300)

var newDateTime = new GlideDateTime(date);
newDateTime.addSeconds(300);

gs.eventQueueScheduled("event_name", current, current.owner, current.owner.getDisplayValue(), newDateTime);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

same code im trying ankur, but email is not triggering