Understanding ServiceNow Tables & Columns

sayub
Tera Contributor

I am new to ServiceNow and i want to start reporting in ServiceNow using PA. Although i understand that CMDB_CI and Task are the main Core

tables; and then there are bunch of parent and extended tables in Service e.g. incident/Application and other derived tables from the Core tables etc.

I want to report on Cloud account and cloud billing cost/incidents/changes and other discovery related data such as applications/software etc. Now i see incident tables that is derived

from Task; but i am getting confused when there are whole bunch of extended tables; and to add to the confusion i see multiple tables for cloud billing and then there are bucket tables called pa_bucket and group etc etc used for breakdowns in reporting.

Is there is crash course document that i can refer to which has table list along with what data that table has (not just the core/base because i see it on service now doc)

so it contains description of value in the table for easier reference (sys_dictionary only shows the table and columns but no description). Or even if someone has documented e.g. 50 main tables used for reporting all the time; will be really helpful as well

Also is there is a way to query only the table name in the sys table list that are not empty and have more than 1 record in the table.

Thanks,

Sheikh

6 REPLIES 6

sayub
Tera Contributor

Nevermind found a script to get that info:



var table = new TableUtils("cmdb_ci");


var table_string = String(table.getAllExtensions());


var mod_table_str = table_string.slice(1, -1);


var table_array = mod_table_str.split(",");


for(i in table_array){


              var table_name = '';


              if(table_array[i].indexOf(" ") == 0)


                      table_name = table_array[i].slice(1);


              else


                      table_name = table_array[i];


              var count = 0;


              var cis = new GlideRecord(table_name);


              cis.query();


              count = cis.getRowCount();


              if(count > 0)


                      gs.print(table_name + " - " + count);


}


sayub
Tera Contributor

This is a new script: which shows rows of all tables:



var grDictionary = new GlideRecord('sys_dictionary');


grDictionary.addQuery('internal_type', 'collection');


grDictionary.addQuery('name','!=','sys_template');


grDictionary.query();


gs.log('MLK Dictionary Query: ' + grDictionary.getEncodedQuery() + ' = ' + grDictionary.getRowCount());


while (grDictionary.next()) {


var currentTable = grDictionary.name.toString();


var count = new GlideAggregate(currentTable);


count.addAggregate('COUNT');


count.query();


if (count.next()) {


gs.log('MLK Table Count: Table: '+currentTable+ ' contains '+ count.getAggregate('COUNT') + ' rows.');


}


}