
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2024 03:53 PM
I have a requirement to automatically update the Class (table) of a CI if the Model ID changes. While the Configuration Item table has Class as a System Class Name type, Model has CMDB CI Class but that is a string, and Model Categories has CI Class which is a Table Name type.
None of these types are the same so there doesn't seem to be an easy way to handle this via a simple Business Rule, and I'd really like to avoid scripting every possible scenario to have it update automatically. Has anyone run into a similar situation that they've created a solution for?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2025 11:00 AM
I ended up creating before Business Rule that triggers when Model ID changes and runs the following script. Seems to work consistently.
(function executeRule(current, previous) {
var ciClass = current.getValue("sys_class_name"); // Get current sys_class_name
// Get the Model Category CI Class
var modCatClass = "";
if (current.model_id) {
var modelGR = new GlideRecord("cmdb_model_category");
if (modelGR.get(current.model_id.u_primary_category)) {
modCatClass = modelGR.getValue("cmdb_ci_class");
}
}
// Updating sys_class_name requires GlideRecord on the same table
if (modCatClass && ciClass !== modCatClass) {
var updateGR = new GlideRecord(current.getTableName());
if (updateGR.get(current.sys_id)) {
updateGR.setValue("sys_class_name", modCatClass);
updateGR.update(); // Save the change
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2024 05:48 PM
Hi @Marcel H_ ,
you can write br on model I’d change and set the files value in action section , no need of writing scripts.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 11:44 AM
The problem is that since the fields on each of the 3 tables; CI, Model and Model Category, are different field types you can't even select any of the fields to set to Same As.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2025 11:00 AM
I ended up creating before Business Rule that triggers when Model ID changes and runs the following script. Seems to work consistently.
(function executeRule(current, previous) {
var ciClass = current.getValue("sys_class_name"); // Get current sys_class_name
// Get the Model Category CI Class
var modCatClass = "";
if (current.model_id) {
var modelGR = new GlideRecord("cmdb_model_category");
if (modelGR.get(current.model_id.u_primary_category)) {
modCatClass = modelGR.getValue("cmdb_ci_class");
}
}
// Updating sys_class_name requires GlideRecord on the same table
if (modCatClass && ciClass !== modCatClass) {
var updateGR = new GlideRecord(current.getTableName());
if (updateGR.get(current.sys_id)) {
updateGR.setValue("sys_class_name", modCatClass);
updateGR.update(); // Save the change
}
}
})(current, previous);