- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 08:53 AM
Hi All!
I am looking for help to update the related CI on an Incident Record's Operational Status based on the Resolution code of the Incident.
E.g. Incident is closed with Resolution Code 'Retired' and CI on Incident is 'Laptop', how can we trigger the Laptop CI record to auto update it's Operational Status to 'Retired' ?
Thank you!
Alex
#cmdb #itms #incident
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 09:02 AM
@alex2410 You need to create a business rule which triggers when the incident state changes to resolved. You can do a glide record query in the business rule script to fetch the CI and update its operational status based on the resolution code of the incident.
Here is the sample script.
// Initialize a new GlideRecord for the cmdb_ci table
var ciGR = new GlideRecord('cmdb_ci');
// Query for the CI you want to update by its sys_id or another identifying field
ciGR.get('sys_id', current.cmdb_ci); // Replace with the actual sys_id or any other condition
// Check if the record exists
if (ciGR.isValidRecord()) {
// Update the operational status field
if(current.close_code=='retired'){
ciGR.setValue('operational_status', 6); // Replace 6 with the actual value for the desired operational status
// Update the CI record in the database
var updated = ciGR.update();
// Check if the update was successful
if (updated) {
gs.info('CI operational status updated successfully.');
} else {
gs.info('Failed to update CI operational status.');
}
}
} else {
gs.info('CI not found.');
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 09:02 AM
@alex2410 You need to create a business rule which triggers when the incident state changes to resolved. You can do a glide record query in the business rule script to fetch the CI and update its operational status based on the resolution code of the incident.
Here is the sample script.
// Initialize a new GlideRecord for the cmdb_ci table
var ciGR = new GlideRecord('cmdb_ci');
// Query for the CI you want to update by its sys_id or another identifying field
ciGR.get('sys_id', current.cmdb_ci); // Replace with the actual sys_id or any other condition
// Check if the record exists
if (ciGR.isValidRecord()) {
// Update the operational status field
if(current.close_code=='retired'){
ciGR.setValue('operational_status', 6); // Replace 6 with the actual value for the desired operational status
// Update the CI record in the database
var updated = ciGR.update();
// Check if the update was successful
if (updated) {
gs.info('CI operational status updated successfully.');
} else {
gs.info('Failed to update CI operational status.');
}
}
} else {
gs.info('CI not found.');
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 01:20 AM
Hi @Sandeep Rajput ,
Thank you so much for getting back to me, this was a massive help and I'm almost there with it!
The issue I have now is, the operational status and install status are on the cmdb_ci table, these are both updating depending on incident resolution details.
However, I also need to update a 3rd field which is on a custom cmdb_ci table.
E.g . -

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 01:33 AM
@alex2410 Could you please let me know about the structure and relation of this third custom table with your record in cmdb_ci table?
Since I already addressed your original question, please mark my initial response as an accepted solution.