Get display value field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 08:59 AM
Using the table API, I am trying to filter my query by a reference display value.
This is what I originally had in mind:
~/api/now/table/customer_account?sysparm_query=primary_contact.display_value={DisplayValue}
Since this doesn't work, I looked into what field is used for display value. I found that the customer_contact table uses the name field, so I changed my query to:
~/api/now/table/customer_account?sysparm_query=primary_contact.name={DisplayValue}
My issue is that all of this needs to happen programmatically. I've been trying to find a table or something that I can pull back from the table API that explicitly states the field used for a references display value. The only thing that I have found to bring back the display fields is:
~/api/now/ui/meta/{table}
This endpoint returns information for each column and the primary_contact reference column for the customer_account table looks like this:
Secondary question, the ~api/now/ui/meta endpoint doesn't seem to have documentation. Is it documented?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2024 03:17 AM
Hi, you can get it from the Dictionary table:
/api/now/table/sys_dictionary?sysparm_query=name={TABLENAME}^display=true&sysparm_fields=element
However, since a table may extend another, the display field might be defined in one of its ancestors. In that case, you can use this:
var queryGen = new GlideCollectionQueryCalculator();
queryGen.buildDictionaryQueryClause(TABLENAME);
For instance, with "incident" as TABLENAME, you get this:
name=incident^ORnameINincident,task
Regarding your question about the /api/now/ui/meta/{table} endpoint, it isn’t officially documented in ServiceNow’s REST API documentation. It is primarily used internally by the platform and the UI framework.