When navigating to a field in the CMDB infrastructure and clicking configure label message "record not found" is displayed


Description

When navigating to a field in the CMDB infrastructure and clicking configure label can receive the message "Record not found" displayed

When the CMDB table is using the table per hierarchy infrastructure, there will be a dictionary record for each child column

Let's say you have the field named u_test_field on the cmdb_ci table, any table extending cmdb_ci will have its own dictionary item. This would be known as a clone descendent

This dictionary record should have its own label which is stored within the sys_documentation table

The error occurs when the label in sys_documentation is missing


Release or Environment

All releases using table per partition for CMDB

This can be validated by navigating to sys_db_obect and searching for table cmdb. The extension model field will display which hierarchical model is used

Resolution

The following script will check all dictionary records contained within the CMDB infrastructure and validate if they have a label. if they do not it will be created from the column_label field within the dictionary record

For fields sys_created_by, sys_created_on, sys_updated_by and sys_updated_on they will be crearted using the default OOB known labels

Amend dryrun variable to 1 when you wish to perform the update

Script:

var strParentTable = "cmdb";
var dryrun = 1; // 1 for checking 0 for live
// this is to get all table extension including parent table
var tu = new TableUtils(strParentTable).getAllExtensions();
for (var tbl = 0; tbl < tu.size(); tbl++) {
propagateDocToChildren(tu.get(tbl));
}

// this is to run on each record of sys_dictionary
function propagateDocToChildren(pTable){
var dic = new GlideRecord('sys_dictionary');
dic.addQuery('name', pTable);
dic.query();

while(dic.next()){
gs.print('Checking Doc table for Tbl:' + dic.name + ' Element:' + dic.element);

switch(dic.element.toString()) {
case 'sys_created_on':
clbl = 'Created';
break;
case 'sys_created_by':
clbl = 'Created By';
break;
case 'sys_updated_by':
clbl = 'Updated By';
break;
case 'sys_updated_on':
clbl = 'Updated';
break;
default:
clbl = dic.column_label;
}

propagateDoc(dic.name,dic.element,clbl);
}
}

//this is to run on each record of sys_documentation
function propagateDoc(pTable,elem,cLbl){
var doc = new GlideRecord('sys_documentation');
doc.addQuery('name', pTable);
doc.addQuery('element', elem);
doc.query();
if (doc.hasNext()) {
gs.print('Skipping record found for Tbl:' + pTable + ' Elem:' + elem);
} else {
gs.print('No doc record found for Tbl:' + pTable + ' Elem:' + elem + ' Column Label:' + cLbl);
gs.print('Adding new doc for ' + elem + ' to ' + pTable);
if(!dryrun){
doc.setNewGuid();
doc.setValue('name', pTable);
doc.setValue('label', cLbl);
doc.setValue('plural', cLbl);
doc.setValue('element', elem);
doc.setValue('language', 'en');
doc.insert();
}
}
}

Additional Information

The script should always run with dryrun variable set as 1 to validate before performing the actual update by setting dryrun to 0

The script should be tested in a sub-production instance which is a clone of production before being applied in a production environment