schedule job script not executing, the script works in background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 06:22 AM
Hi Team,
I am facing this unusual issue where a schedule job does not trigger for a schedule job, however the same works when run from background script.
The condition is something like this
var chg = new GlideRecord('change_request');
chg.addEncodedQuery('active=true^end_dateRELATIVELE@dayofweek@ago@7^state=0');
//chg.addEncodedQuery('active=true^end_dateRELATIVELE@dayofweek@ago@7^state=0^assignment_group.nameSTARTSWITHservicenow^number=CHG0041873');
chg.query(); gs.log('chg 001');
while(chg.next()){
gs.log('chg 002');
chg.state="4";
chg.close_code= 'Auto-terminated in review';
chg.close_notes ='Auto-term abandoned as change exceeded 7 days after the planned end date.';
chg.work_notes ='Auto-term abandoned as change exceeded 7 days after the planned end date.';
chg.update();
gs.log('chg 003' +chg.number);
}
This although is supposed to run everyday at 23:50 , but there is no trace in the sys_trigger table.
Also, please note when i force execute it , the logs can be seen but not the action, i.e. change does not updates/closes.
Btw, i have similar scheduled scripts running for the condition, all running in global application
var chg = new GlideRecord('change_request');
chg.addEncodedQuery('active=true^end_dateRELATIVELE@dayofweek@ago@7^state=-2');
chg.query();
while(chg.next()){
chg.state=4;
chg.close_code= 'Auto-terminated in scheduled';
chg.close_notes ='Auto-term abandoned as change exceeded 7 days after the planned end date.';
chg.work_notes ='Auto-term abandoned as change exceeded 7 days after the planned end date.';
chg.update();
}
Can you please point me towards something useful?
Regards,
Shariq
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 07:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 09:57 PM
We have still not accommodated flow designer in our development yet. so maybe not now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 07:37 AM
The change process is workflow driven, why not just add a timer into the workflow and cancel it from there if the time elapses?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 09:56 PM
Good approach, however, Ill have to change the workflow and will update you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 05:25 AM
Hello Shariq,
Did you get a chance to resolve this issue, because I'm also facing the same issue.
This is the code given below, I'm able to update the records from background script but when I tried it with scheduled job, it is not working. Can you please help me on this
var core = new GlideRecord('core_company');
core.addEncodedQuery('u_taq_valid_days_remaining!=NULL');
core.query();
core.getRowCount();
while(core.next()) {
var date = core.u_taq_valid_days_remaining.getValue();
year = date - 1;
core.setValue('u_taq_valid_days_remaining', year);
core.update();
}
Thanks and regards.