Creating Schedule job to send notification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2019 12:15 PM
Hi,
I have to create a scheduled job which will run daily to send a notification to the caller of the incident, if the ticket is in active state for more than 5 days.
Below is the script I have written in the Schedule job-
var gr = new GlideRecord('incident');
gr.addQuery('state', 'Active');
gr.addQuery('sys_created_on', '<', gs.daysAgo(5));
gr.query();
while(gr.query()){
gs.eventQueue('Incident.Active',gr, '','');
}
I have registered an event called Incident.Active and created a notification. I have not added any condition/script in the notification.This is not working though. Can someone please explain me my mistake?
I am very new to Servicenow and any help is appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2019 12:16 PM
Hi,
Thanks for the help Sachin, I ran the script in Scripts background, the problem was in the gr.addQuery('state', 'Active') , using the value of state worked gr.addQuery('state', '-1').
I didn't need to pass event parameters, it worked by using value of state.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2020 08:24 AM
I followed this process for a time sheet issue I was working on and this did 90% of what I needed. The only piece that i ran into was that it sent multiple instances of the email to the managers.
My request was to send managers a reminder that they had submitted time sheets pending their review. I followed the above process and tweaked it to work for time_sheets rather than kb_knowledge. I need to find a way to compile the information and only send 1 notification per manager.
Any insight is greatly appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2020 08:34 AM
Can you share your script where you are generating your events?
You will have to update code before generating events which sends notifications?
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2020 08:42 AM
It is very rudimentary:
var gr = new GlideRecord('time_sheet');
gr.addEncodedQuery('state=Submitted');
gr.query();
while (gr.next()) {
gs.eventQueue("timesheet.mgrreminder", gr);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2020 08:52 AM
If you want to send reminders to manager, then you can configure workflow on time_sheet table to sent unique email for sending reminders.
I implemented similar requirement in our instance by configuring workflow on to send approval reminders.
Please see workflow below
Regards,
Sachin