Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

All fields of table not present in sys_dictionary

qusai
Kilo Contributor

I have a doubt that in my sys_db_object table when i go to incident table and see the fields there are around 100 fields for the table.But in sys_dictionary if i search for incident table there are only 25 fields so why do sys_dictionary does not contain all the fields of the particular table ...If not how can i see all fields in sys_dictionary table as we want to use that table to view fields in our ui page slushbucket

1 ACCEPTED SOLUTION

Below is the complete solution

Use reference qualifier as javascript: 'sys_idIN' + new ScriptInclude().returnFields(tableName);

Use the below script include

returnFields : function(tableName){

var fieldArray = [];
var extendsTable = "nothing";


fieldArray.push(getRecords(tableName));
var extendsTable = getParentTable(tableName);
while (extendsTable != "none"){
fieldArray.push(getRecords(extendsTable));
extendsTable = getParentTable(extendsTable );
}
return fieldArray;
},

getRecords: function (tableName){
var dictfields = new GlideRecord('sys_dictionary');

                           dictfields.addQuery('name',tableName);
  
                           dictfields.query();

                    while(dictfields.next())
                    {
                        var obj={};
                        var wel=dictfields.getDisplayValue('column_name');
                        var text=dictfields.getDisplayValue('column_label') ;
                        obj.value = wel;
                        obj.text=text;
                        arr_dict_fields.push(obj); 
return arr_dict_fields;
   
   
                    },


getParentTable: function(tableName){
var dbObject = new GlideRecord('sys_db_object');
dbObject.addQuery('name',tableName);
dbObject.addEncodedQuery('super_classISNOTEMPTY');

dbObject.query();

if (dbObject.next()){

return dbObject.super_class.name.toString();
}
else{
return "none";
},

View solution in original post

17 REPLIES 17

Hello,

I think we can make use of label field in sys_db_object table !

Can you try that and let me know if it is working ?

 

no @Mohith Devatte changing column_label to label is not working

@qusai 

@Mervin has already explained the reason and has provided correct answer.

What's the issue?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

suvro
Mega Sage

sys_dictionary contains fields created for that table and sys_db_object also contains fields inherited from parent tables

qusai
Kilo Contributor

So what can i use if i want to display all fields in slushbucket ui page @suvro 

 var dictfields = new GlideRecord('sys_dictionary');

                           dictfields.addQuery('name',tableName);
                           
                         dictfields.addEncodedQuery(strQuery);
                           dictfields.query();

                    while(dictfields.next())
                    {
                        var obj={};
                        var wel=dictfields.getDisplayValue('element');
                        var text=dictfields.getDisplayValue('column_label') ;
                        obj.value = wel;
                        obj.text=text;
                        arr_dict_fields.push(obj);                 
                        
                        
                    }