"Table Name" and "Field Name" types does not have a Display Value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 01:18 AM
You know there are certain field types on a table, and two of the less known are "Table Name" and "Field Name". You can make the Field Name dependent on the Table Name and there you have a nice way to pull tables and their fields, and do some tricks with them. They are supposed to be some kind of reference fields. And as we know Reference fields usually have a Name (e.g: sys_created_on) and a Label (e.g.: Created).
The problem is that it looks impossible for me to pull the Lables with getDisplayValue() on these two field types. Also tried getValue() without success.
So I tried to find out whats going on.
When I create a dummy test table and create one "Table Name" and one "Field Name" field on it (bold tags), and then I click "Show XML" I see:
- Labels:
-
Platform and Cloud Security

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 01:22 AM
Hi
Try with getValue() only once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 01:40 AM
As I mention in the article I tested this with getValue, like this small background script:
var tableGR = new GlideRecord('u_totestfieldnametype');
tableGR.query();
while (tableGR.next()) {
var name = tableGR.u_name_of_the_table;
var value = tableGR.getValue('u_name_of_the_table');
gs.info('Name / Value: ' + name + ' / ' + value);
}
And the result is:
*** Script: Name / Value: task / task
*** Script: Name / Value: change_request / change_request
*** Script: Name / Value: incident / incident
You see? It just won't give back any other value than its internal name, like "change_request".
So my guess is that "Table Name" and " Field Name" field types are not implemented correctly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 01:46 AM
Hi
Just go with tableGR.u_name_of_the_table.value from the above code.
Else i guess it is configured incorrectly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2020 10:30 PM
Here's the answer:
You need to query the sys_db_object table, i.e. the table of tables, and get the Label of the table, using it's name to query for it.
var tableName = current.u_name_of_the_table.getValue();
var dbo = new GlideRecord('sys_db_object');
dbo.addQuery('name', tableName);
dbo.query();
if(dbo.next()){
var displayName = dbo.getValue('label');
}​