CI operational status should be Non-Operational in cmdb_ci table.

Phanideepthi
Tera Contributor

When we move the catalog task to close the server then the CI operational status should be Non-Operational in cmdb_ci table.

Please suggest how to achieve this using run script in Workflow.

This is the script we are using. Please correct where we are missing or if there is any issue with the script.

var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name', current.sc_cat_item.variables.server_name);
gr.query();
while (gr.next()) {
gr.operational_status = 2;
gr.update();
}

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

@Phanideepthi 

var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name', current.variables.server_name.toString()); //server name is what type of field? if it is reference replace name with sys_id
gr.query();
while (gr.next()) {
gr.operational_status = 2;
gr.update();
}

 

Thanks

Thanks,
Murthy

View solution in original post

3 REPLIES 3

Murthy Ch
Giga Sage

@Phanideepthi 

var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name', current.variables.server_name.toString()); //server name is what type of field? if it is reference replace name with sys_id
gr.query();
while (gr.next()) {
gr.operational_status = 2;
gr.update();
}

 

Thanks

Thanks,
Murthy

Hi Murthy,

 

Thanks for the response. 

Yes it is a reference field, which is getting data of name field of cmdb_ci table.

var gr = new GlideRecord('cmdb_ci');
gr.addQuery('sys_id', current.variables.server_name.toString());
gr.query();
while (gr.next()) {
gr.operational_status = 2;
gr.update();
}

 

Is it fine now?

Yes correct.

 

Thanks,

Murthy

Thanks,
Murthy