- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2015 09:42 PM
Hi,
I would like to send an email notification X days after the incident state is to 'Awaiting User Info'. I created a new notification, in the When to send section, I need two conditions:
1. Incident state is 'Awaiting User Info'
2. This is the part I'm struggling with. I tried setting Updated relative on 5 days from now but nothing was sent. I tried a couple of other options as well and none worked so far. I could use some help on this.
Thanks,
James...
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2015 07:59 PM
Hi James Li
Perfect ..Also can you please enclose your code in a function.
Would you mind marking the answer as correct if this answers your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2015 10:00 PM
Hi James,
You have to construct your query and run that as a part of schedule job which will run daily(as per the time defined) and will fire the event if the condition satisfy.
To proceed with this you'll need to define a new event.Then you can add your 'gs.eventQueue' line to your script to trigger that event.
gs.eventQueue('EVENT_NAME', gr, gs.getUserID(), gs.userName());
Creating a Scheduled Job - ServiceNow Wiki
Events and Email Notification - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2015 06:55 PM
Hi Pradeep,
Thank you for the suggestion on using Scheduled Jobs to trigger events. I was able to find an example on how to use the search conditions and update incident record from the ServiceNow wiki. I have tested the below and it worked!
var ps = 10; //number of days
var pn = parseInt(ps);
if (pn > 0) {
var gr = new GlideRecord('incident');
gr.addQuery('incident_state', '4');
gr.addQuery('sys_updated_on', '<', gs.daysAgoStart(pn));
gr.addQuery('assignment_group', 'ee04b75c0f3e710045e549bce1050ea0');
gr.query();
while(gr.next()) {
gr.incident_state = '6';
gr.comments = 'This Incident has been automatically marked as Resolved by the system since after 10 days in the Awaiting User Info state there has been no further update. If the incident has not been resolved to your satisfaction and you would like to keep the incident open, simply reply to this e-mail with your latest comments and the incident will be automatically reactivated for you. If you do not reply and there is no update within the next 10 days then the incident will automatically be closed by the system. We appreciate your business and the opportunity to serve you.';
// gr.active = false;
gr.update();
}
}
Regards,
James...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2015 07:59 PM
Hi James Li
Perfect ..Also can you please enclose your code in a function.
Would you mind marking the answer as correct if this answers your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2017 09:29 AM
Hi James,
Where exactly did you write that code?
Thanks!