What is the difference between current.getTableName() and current.sys_class_name in terms of operation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2014 11:10 PM
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.
- 60,347 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2017 06:15 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 08:14 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 08:29 AM
you can use getDisplayValue()
for example:
gr.sys_class_name would give sysapproval_group
gr.sys_class_name.getDisplayValue() would gvie Group approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2019 09:22 PM
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.