The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Script to retire configuration items

Luqman Khalid
Tera Contributor

I have a client requirement to create a scheduled job to retire all the configuration items. Client is asking to retire all the configuration items using scheduled job. Scheduled job should process 5000 records at a time and run till all the records are set to be retired.

I am creating a scheduled job which will have a script as:

 

var gr = new GlideRecord('cmdb_ci');

gr.query();

while(gr.next()){

gr.operational_status = 6;

gr.update();

}

 

I am not sure how do I set this for 5000 records at a time and run the job till all the records are updated. Your suggestion is appreciated.

 

Regards,

Luqman

2 REPLIES 2

Yousaf
Giga Sage

Hi,

You can use something like this in query to limit the records 

gr.setlimit(5000);


Thanks

Yousaf


***Mark Correct or Helpful if it helps.***

Hi Luqman if i helped you in any way can you mark my answer helpul or correct.

 

Thanks,
Yousaf


***Mark Correct or Helpful if it helps.***