- 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: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:46 AM
Hello Asif,
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
‎06-10-2020 11:57 PM
Hi Swaroop,
As already suggested by Asif please add some logs in the condition and check if it is going inside and giving any error or not
What you can do is try running this script in background to check whether it returns true/false
gs.info(getValue());
function getValue(){
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;
}
}
return answer;
}
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:08 AM
Hello Ankur,
When i ran the script in Background it returned False.
Thanks & Regards,
S.Swaroop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 12:18 AM
Hi Swaroop,
so it means it must be failing because of either of the schedule
please check for which one it is failing
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader