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,

Can you check the date field is correct name?

Can you share complete BR script?

Regards
Ankur

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

Swapnil Soni1
Giga Guru

Hi,

You should already have standard triggers for sending an email on a resolution.   For the other timings, the easiest way is to set up a workflow with a 'timer' activity for the specified intervals.   You'll want to include a second path in your workflow that waits for the incident to be resolved and then immediately ends the workflow so that you don't end up sending emails even though the ticket has been resolved.

 

 

 

You could set this up with a custom workflow or leverage the SLA definitions to accomplish it.

 

 

 

Please mark this as the correct answer if it solves your problem.

Mohit Kaushik
Mega Sage
Mega Sage

Hi There,

You can create a scheduled job to trigger an event after 48 hours of no update in UAT state. Following script should work.

 

var story = new GliderRecord('rm_story');

story.addQuery('state',<backend value for UAT>);

story.addEncodedQuery('sys_updated_onRELATIVELT@dayofweek@ago@2');

while(story.next())

{

gs.addeventQueue('event name', current); // pass the name of the event you have already created in event registry table. Then create a notification on story table where you will trigger it when the event is fired.

}

This will work for your notification to trigger after 48 hrs of being not updated in UAT state.

 

Please mark this correct and helpful if it resolves the query as per the impact.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

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

Thanks Asif. its working correctly. i want to add the query for 2 days is it possible