- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 02:31 AM
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();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 02:42 AM
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
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 02:42 AM
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
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 09:15 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2022 08:34 PM
Yes correct.
Thanks,
Murthy
Murthy