
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 03:33 AM
Hi All,
I have a requirement to send an email notification on a certain day of the month. I am trying to achieve this through an event using a scheduled job.
This is what I have so far in Dev to test this -
Event
Scheduled job
Notification
I believe the issue is with the script for the scheduled job?
Or is there a different/easier way to achieve this?
Any help would be much appreciated.
Thanks,
Alex
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 04:07 AM
Okay. Then do it like this in your scheduled job.
var gr = new GlideRecord("incident");
gr.setLimit(1);
gr.query();
if(gr.next()) {
gs.eventQueue('patching_email',gr,gs.getUserName(),gs.getUserID());
}
Event/notification runs on a specific record. Since in your case, its just a static mail.. we just pass any 1 incident object. Hence using setLimit(1).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 03:37 AM
In the scheduled job you are passing gr but it is not defined, you should ideally use a glide record query for the record the email should be sent for, that would be your GR.
For Eg,
the scheduled job would be something like
gar gr = new GlideRecord('incident');
gr.get('<sys_id of an incident>');
gs.eventQueue('patching_email', gr, 'abc@example.com', '');
In this case the email would refer to the incident associated with gr
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 03:52 AM
Hi Anurag,
Thanks for you help.
Can you please explain this one a bit more, I'm not sure why I have to include a sys_id of an incident and an email? And if I do, can this be any incident?
Thanks,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 03:55 AM
An email in ServiceNow is trigger against a record, it can be an incident, change, anything like that.
Can you tell me what is your email and what will it contain?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 04:04 AM
Hi Anurag,
The email is only text, it does not need to include any information regarding tickets.
Thanks!
Alex