- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2015 08:44 AM
How can I getDisplayValue on a field while I am working in a UI Policy?
When certain criteria is met with what the user selects, I want to populate the short description with the value of the choice list. I can get the sys_id of course, what is the easiest way for me to get the display value of said field?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2015 03:25 PM
Hello Jeremy,
You can get the display value of the reference field with the below piece of code.
var caller = g_form.getDisplayBox('caller_id').value; //Replace caller_id with the exact field column name as per your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2017 11:52 AM
I would argue that it is a very bad idea to use getDisplayBox in production code. This method is not in the api documentation, and is also not displayed in the SN script "intellisense" popup. I would not be surprised if this method was deprecated already.
I would argue that the best practice would be to create a glideajax call using the sys_id from g_form.getValue to fetch the field display value from a client callable script include that queries the same table the reference field variable is attached to.
http://wiki.servicenow.com/index.php?title=GlideAjax#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2017 11:36 AM
Within the same UI policy, how can I get the old value of a field?
Thanks!
Charlie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 11:21 AM
I realize this is an old thread, but thought it is important to point out that g_form.getDisplayBox does not appear to work in Service Portal.
Also, if you need to use GlideAjax in an onSubmit script to get a display value, you will need to do some additional work. After your async call, you will need to cancel the submit (return false) and then re-submit the form at the end of your callback. Otherwise the system will not return a value before the form submits. That assumes you need the value before the form submits. This does not apply to UI policy but is important to note for client scripts.