How to get some fields in raw value and other in display value from one Table API query?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 04:36 AM
I would like to create a URL query to receive certain fields from the Table API.
But I want some fields to be displayed in display value and some of them in raw value.
This is because, I want to keep the labels of specific fields, but I want any date/time format fields to be displayed in raw value as the display_value of such date/time fields doesn't provided all of the necessary information.
So I want text based fields to have
'sysparm_display_value=true',
But date/time based fields set to
'sysparm_display_value=false'.
Right now, my query looks like:
https://<instance name>.service-now.com/api/now/table/interaction?sysparm_display_value=All&sysparm_fields=number,sys_class_name,wait_time,duration
And it displays both display and raw values for each field, but it demands a lot of backend processing, to display the right form at the end.
Thus, my question is if there is a way to display date/time fields in raw value and other fields in display value. I would like to have both included in one URL Table API rather than two separate ones.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 05:34 AM
Hi,
Here is the catch. The table API do not have all the functionality means either you can have the display value true for all the fields or not.
Now for your case you need to go for Scripted REST and configure the changes as per the needs.
Mark this as Helpful/Correct if applicable. Thanks.
Regards,
Sourabh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 08:57 AM
Hi Jan,
I understand your challenge with wanting to display some fields in display value and others in raw value within a single API call. I faced a similar issue and found a workaround that might help you achieve this without needing extensive backend processing.
Workaround Using Dot-Walking
Instead of using "sysparm_display_value=all", which returns both display and raw values for all fields, you can use dot-walking to selectively get the display values for specific fields. This way, you can keep the raw values for date/time fields and get the display values for text-based fields.
Example
Given your current query:
https://<instance name>.service-now.com/api/now/table/interaction?sysparm_display_value=All&sysparm_fields=number,sys_class_name,wait_time,duration
You can modify it to use dot-walking for the fields you want in display value. For instance, if you want the "number" and "sys_class_name" fields in display value and "wait_time" and "duration" fields in raw value, you can do the following:
https://<instance name>.service-now.com/api/now/table/interaction?sysparm_exclude_reference_link=true&sysparm_fields=number.sys_id,sys_class_name.sys_id,wait_time,duration
Explanation
- `sysparm_exclude_reference_link=true`: This parameter excludes reference links from the response.
- Dot-Walking: By using `number.sys_id` and `sys_class_name.sys_id`, you are effectively dot-walking to get the display value of these fields.
It's important to note that "sys_id" is not necessarily the display value for a field. A good practice would be to query the table from which the "number" field is coming and identify the actual display value field.
Result
This approach will give you the display values for `number` and `sys_class_name`, while keeping `wait_time` and `duration` in their raw format. This reduces the need for extensive backend processing and allows you to format the data as needed.
I hope this helps!