
- 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 04:07 AM
It still needs to be tied to a record, that is just the way it is. I understand this is a limitation but this is how you can achieve this.
Since you don't need to include any information of a record, you can use any hardcoded test record to trigger the notifications.
You can pick any small table from your instance, and just have this code below
var gr = new GlideRecord('<your table name>');
gr.get('<sys_id of any record on that table>');
gs.eventQueue('patching_email', gr, '', '');
Done 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 04:17 AM
If your question is answered, please mark my response(or anyone else also if that helped you more) as correct/helpful and close the thread 🙂
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 03:39 AM
Hi Alex,
If you want to send email for specific condition then try below code
var gr = new GlideRecord("incident");
gr.addQuery(<your query>);
gr.query();
while(gr.next())
gs.eventQueue('patching_email', gr);
or else try below code
var gr = new GlideRecord("incident");
gr.query();
if(gr.next())
gs.eventQueue('patching_email', gr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 03:40 AM
HI,
This wont work as scheduled jobs don't have current object.
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 03:44 AM
Yes you are right Anurag.
I have edited my answer