- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 11:00 PM
Hello,
I am having a schedule job which will run every 30Min and Daily. When i manually use "Execute Now" UI Action, it was working as expected but only when i manually did, it is working but it was working automatically based on the time(30Min) provided. Below is the condition and script i am using in Scheduled job.
Condition -
var answer = false;
var s = new GlideSchedule("e939ddfcdb2c98501317f27139961981"); - For validating Business hours
var w = new GlideSchedule("55ebbbf15f002000b12e3572f2b47714"); - For Validating US Holidays
var gdt = new GlideDateTime();
if(gdt.getDayOfWeek() >= 1 || gdt.getDayOfWeek() <= 5){
if(s.isInSchedule(gdt)&&!w.isInSchedule(gdt)){
answer = true;
}
}
Script -
var gr = new GlideRecord("incident");
gr.addEncodedQuery('sys_created_onRELATIVELT@minute@ago@40');
gr.addQuery('assigned_to',"");
gr.addQuery('active',true);
gr.query();
while(gr.next())
{
gs.eventQueue("trigger.incident.unassigned",gr);
gr.u_ntfctn_flag = true;
gr.update();
}
I cant able to figure out why it working as expected when i did it manually but not triggering automatically after every 30Min.
Please suggest me if i did wrong anywhere in the script.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 12:24 AM
Hi Swaroop,
As per the screenshot it is scheduled to run daily once at 05.
Instead of Daily, select repeat and then select 30 mins then it will run every 30 mins.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 12:22 AM
Hello Ankur,
I have validated, it was getting failed because one of the schedule is validating Business hours, so i have removed that schedule and ran the script and it returned "True".
But in my Scheduled job i have removed the condition completely and waiting, still it was not triggering. I have kept logs as well, when i did manually it was working but when i am waiting for automatic trigger it was not working as expected.
Thanks & Regards,
S.Swaroop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 12:34 AM
Hi Swaroop,
job is set to run daily; as said by Asif please use repeat and then select 30 mins then it will run every 30 mins.
Try that
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 12:46 AM
Hello Ankur,
It worked perfectly, Thank you very much.
Thanks & Regards,
S.Swaroop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 08:21 AM