get the display value of the reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 02:44 AM
Hi All,
I have a catalog item where I use a reference field and a text field.
I would like the text field to have the exactly the same value as the reference field:
this works on the backend with the following client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var groupDisplayValue = g_form.getDisplayBox('group').value;
// Set the 'group_name' field to the display value of 'group'
g_form.setValue('group_name', groupDisplayValue);
}
This does not work in ESC as I am getting a JS error that getDisplayBox() doesnt work.
I tried to use the 'getDisplayvalue()' instead but it does not work

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 02:52 AM
@dev_K getDisplayBox doesn't work in case of Service Portal. You can get the display value via one of the following approaches.
1. GlideAjax: Make a server side script include method call using GlideAjax. This method should accept the sys_id of the assignment group as input and should return the display value/name of group based on sys_id
2. g_form.getReference: Make a g_form.getReference('<field_name>',callaback); method call and fetch the value of assignment group name field.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 03:01 AM
On client side you can use the script below to get Display value of reference field
g_form.getDisplayBox('<field name>').value;
Hi,