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

Hi,

Is the event getting triggered? Did it get processed?

Did you use proper event name?

Can you share complete script?

Regards
Ankur

 

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

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

gs.eventQueueScheduled("Test.Uat", current, current.u_apo, current.u_apo.getDisplayValue(),newDateTime);

Hi,

is this trigger from BR?

can you trigger from background script and check?

for testing purpose please remove date

var newDateTime = new GlideDateTime();

Below worked for me

var newDateTime = new GlideDateTime();

newDateTime.addSeconds(60);

var inc = new GlideRecord('incident');

inc.get('68ec5d2c07309410540bf2508c1ed031');

gs.eventQueueScheduled("sample.incident", inc, inc.caller_id, inc.caller_id.getDisplayValue(), newDateTime);

Screenshot: event got generated and processed after 60 seconds

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

yes trying from BR, 

No luck. tried in BG script also, can you provide the proper bg script

Yes ankur. Bg script is working for me also