Script to retire configuration items
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2022 12:57 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2022 03:51 PM
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.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2022 02:52 PM
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.***