How to run a background script to retire servers containing the same name?

Wyatt Fudal1
Tera Guru

Hello Dev forum,

I'm currently practicing in a Dev instance to bulk retire Server class ci's and get a return count of the number of Servers updated via the background script. For this test I'm trying to update the car Servers. My company is fully updating our CMDB and we are starting with our vendor next week so I want get my feet wet with some manual processes.

Thank you

Car Servers.png

 

 

1 ACCEPTED SOLUTION

Wyatt Fudal1
Tera Guru

I figured it out I should have uploaded my code. I miss spelled my table. I had cmdb_ci_servers instead cmdb_ci_server. ðŸ˜‚🤣
Correct code for my test.

updateRecords();
function updateRecords(){
var gr = new GlideRecord('cmdb_ci_server');
gr.addEncodedQuery('nameSTARTSWITHcar');
gr.query();
while(gr.next()){
gr.setValue('install_status','7');
gr.setWorkflow(false);
gr.update();
}
}

var count = gr.getRowCount();
gs.log('number of records: '+count);

View solution in original post

1 REPLY 1

Wyatt Fudal1
Tera Guru

I figured it out I should have uploaded my code. I miss spelled my table. I had cmdb_ci_servers instead cmdb_ci_server. ðŸ˜‚🤣
Correct code for my test.

updateRecords();
function updateRecords(){
var gr = new GlideRecord('cmdb_ci_server');
gr.addEncodedQuery('nameSTARTSWITHcar');
gr.query();
while(gr.next()){
gr.setValue('install_status','7');
gr.setWorkflow(false);
gr.update();
}
}

var count = gr.getRowCount();
gs.log('number of records: '+count);