What is the difference between current.getTableName() and current.sys_class_name in terms of operation

sam352120
Kilo Guru

Hi All,

 

I have used both current.getTableName() and   current.sys_class_name in an existing Business to perform a specific operation .I got the desired output

by using current.sys_class_name ,But that did not work for current.getTableName().Please share your valuable inputs(practical scenario) apart from the Wiki.

 

Thanks in Advance.

13 REPLIES 13

How do get the table label from the sys class name.


  var cmdbci = new GlideAggregate('cmdb_ci');


              cmdbci.groupBy('sys_class_name');


                              //cmdbci.addQuery('sys_class_name', '=', "cmdb_ci_appl");


                              cmdbci.query();


                              var count = cmdbci.getRowCount();


                              gs.log("Total cmdb_ci Class is " + count);


                              while (cmdbci.next())


                              {


                      gs.log("Class is " + cmdbci.sys_class_name);


                              }


Returns cmdb_ci_apache_web_server .   We would like the label value Apache Web Server.



Thanks,


Chad


Sorry to wake up this old post, but does anyone know how to get the label from this? I would want to see 'Linux Server' in the results, not the table, cmdb_ci_linux_server.

you can use getDisplayValue()

 

for example:

gr.sys_class_name would give sysapproval_group

 

gr.sys_class_name.getDisplayValue() would gvie Group approval

Santosh Vaddadi
ServiceNow Employee
ServiceNow Employee

I am just tryying to add to @jschlieszus answer with an example.

As per the internals of servicenow, the records stored under a single table can have different sys_class_name.

Let us say A is a table with sys_class_name record_A and B is a child table extending A. sys_class_name of B is record_B

 

Records in table A that are only of type A will have sys_class_name as record_A where as records in table A that are of type B will have sys_class_name as record_B.

 

For all these records the getTableName() would return A where sys_class_name would record_A or record_B as per the data.

 

-Santosh Vaddadi (Sr Manager, Risk Engineering, ServiceNow)