How to execute a fix script from scheduled job?

rambo1
Tera Guru

Hi,

I calling a script include from scheduled job, but some records are not getting updated.

I am thinking its due to huge data, there are around 4 lakh records and some are not being updated.

So, I am planning to create a fix script and execute it from schedule job for every 6 hours.

Below is the script in scheduled job:

var gr = new GlideRecord('sn_vul_vulnerable_item');
gr.addActiveQuery();
gr.query();
while(gr.next()){
var securityCalc = new sn_vul.VulnerabilityCalculator(gr, true, true, "sn_vul_calculator_group", "sn_vul_calculator");
securityCalc.calculate();
}

I want to move this code to fix script and execute it every 6 hours, please help me with the syntax for this.

Thanks in advance.

8 REPLIES 8

Why do you believe the scheduled job has a time limit?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

because some records are left without getting updated, when I tried fix script they got updated.

asifnoor
Kilo Patron

Hello Rambo,

Go through this link. This should help you to solve the problem.

https://community.servicenow.com/community?id=community_question&sys_id=673db14d1bac5050fff162c4bd4b...

Mark the comment as a correct answer and helpful if it helps to solve the problem.

Servicenow34
Tera Guru

Hi @rambo1 

 

Kindly use below code in schedule job

(function(){

var fixScript = new GlideRecord('sys_script_fix');

fixScript.addQuery('name','fix_script_name');

fixScript.query();

 

if(fixScript.next()){

    eval(fixScript.script);

}

})();

 

Hope this helps !

Kindly mark helpful/accepted if assists.

Thank you!