How to call fix script from schedule job

naresh g
Tera Contributor

Hi Team,

 

Please assist How to call fix script from schedule job 

 

8 REPLIES 8

Priyanka_786
Tera Guru
Tera Guru

Hi @naresh g 

 

Use below code in your scheduled job script. Pass your fix script name in query.

Priyanka_786_0-1707577910047.png

 

Hope it helps. Kindly mark helpful/ accepted if assists you.

Regards,

Priyanka Salunke.

Servicenow34
Tera Guru

Hello @naresh g ,

 

Kindly use below code in the scheduled job.

 

(function(){
var fixScript = new GlideRecord('sys_script_fix');
fixScript.addQuery('name','fix_script_name'); //pass fix script name
fixScript.query();

if(fixScript.next()){
    eval(fixScript.script);
}
})();
 
 
Hope this helps!
Kindly mark helpful / accepted if assists you.
Thank you!

-O-
Kilo Patron
Kilo Patron

Move the code from the Fix Script into and adapt it for a Script Include.

Call a method of the Script Include both from the Fix Script and the Scheduled Job.

KrishnaKamal
Tera Contributor

I believe the existing responses provide valuable insights. However, running a fix script from a scheduled job might not be optimal. Fix scripts, being server-side on-demand scripts, are susceptible to modifications by other developers. It is advisable to consider executing such scripts from a script include. If feasible, replacing the fix script with a script include is also recommended for better maintainability.