- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2018 03:01 AM
I am new to servicenow want to know how to schedule jobs using glide script . Please explain steps with detailed.
My requirement is that i need to trigger a mail before the expiry date to end user. before 15/10/05 days.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2018 02:36 AM
Hi Shilpi,
PFB the steps:
1) Register and event through Event Registry.
2) Configure Notification as below
3) Create a Scheduled job from System definition->Scheduled Job.
4) Select Automatically run a script of your choosing.
5) Create a job with run field as daily and select a particular time on which this job will trigger.(I have selected on demand for test purpose).
6) Write below script under Run this script.
var gr = new GlideRecord('x_197397_test_appl_test123');// give your table name
gr.query();
while (gr.next())
{
//gs.info("expiry date :"+exp);
var dt = new GlideDateTime().getDate();
var dt1 = new GlideDateTime(exp).getDate();
var diff = GlideDateTime.subtract(dt,dt1);
var a = diff.getDisplayValue();
var arr=a.split(" ");
var day =arr[0];
if(day == 15)
{
gs.eventQueue('x_197397_test_appl.Reminder for expiry',gr,gr.caller,gs.getUserID());// give your event name in first parameter and pass the parameter 3rd and 4th as per your requirement
}
else if(day == 10)
{
gs.eventQueue('x_197397_test_appl.Reminder for expiry',gr,gr.caller,gs.getUserID());
}
else if(day == 5)
{
gs.eventQueue('x_197397_test_appl.Reminder for expiry',gr,gr.caller,gs.getUserID());
}
}
Hope this helps.
Regards,
Monika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2018 10:16 PM
Hi Shilpi,
Any update on this?
Regards,
Monika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2018 10:33 PM
I create a schedule job as mention in your post but it is not working don't know why.
I am using Jakarta version and my table name is "incident".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2018 10:36 PM
I am using Jakarta version and my table name is "incident".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2018 10:41 PM
Are you working on OOTB incident table?
Have you also configured event and notification?
If yes then please provide me the screenshot of what you have configured.
Regards,
Monika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2018 10:54 PM