schedule job script not executing, the script works in background script

Sharique Azim
Mega Sage

 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

15 REPLIES 15

Chiranjeevi Go1
Giga Expert

Hi Shariq, 

Just want to know if you had any luck with this situation as I am also experiencing the same issue. Scheduled job used to be run as one of my colleagues who left the organization, so we changed the run as other user, who has the same permission as my previous colleague, since then we started experiencing this issue. 

Scheduled job gets executed, however it doesn't update the records. But when I run the same code in background script, it works fine. Not sure, what's the issue is. Any help in this regard will be much appreciated! 

Thank you,

Chiranjeevi