new field from cmdb_ci in all subclasses specific view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi everyone,
I have a request to create a new field in the cmdb_ci table. After that, I need to add this new field to a specific view across all cmdb_ci classes, under specific field. is that possible or should it be manually?
Something to add: that all classes have created a view with the same name.
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
31m ago
Hi,
Yes, it’s possible to add a new field to the cmdb_ci table and have it appear in a specific view across multiple CI classes, but there are some important considerations:
1. Create the field
You can create the field on the cmdb_ci table. By doing this, the field is inherited by all extended classes automatically.
2. Views across classes
Views are specific to tables, not inherited. Even if all classes have a view with the same name, you’ll need to update each view individually to include the new field in the desired position.
There isn’t a native way in ServiceNow to automatically propagate a field to a view across all extended tables, so this part requires manual work or a scripted approach.
3. Automation option (Scripted Approach)
You can write a GlideRecord script that iterates through all sys_ui_view records with the same name and inserts the new field programmatically.
This is useful if you have many classes and views, as it avoids repetitive manual updates.
Example outline of a scripted approach:
var viewName = 'your_view_name';
var tableName = 'cmdb_ci';
var fieldName = 'new_field_name';
var grView = new GlideRecord('sys_ui_view');
grView.addQuery('name', viewName);
grView.query();
while (grView.next()) {
var viewFields = grView.view_fields.getDisplayValue().split(',');
if (viewFields.indexOf(fieldName) === -1) {
viewFields.push(fieldName); // Add new field
grView.view_fields = viewFields.join(',');
grView.update();
}
}Note: This is a starting point. You may need to adjust it depending on how your views are structured and whether you want to place the new field at a specific position.
✅ Summary:
The field can be created once on cmdb_ci and inherited by extended classes.
Adding the field to views must be done per view, either manually or using a scripted approach.
Was this explanation helpful? If so, please mark it as correct!
Carlos Petrucio
ServiceNow Developer
