Unable to get value of referance field in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 03:16 AM
I am trying to get value of ref field in client with g_form.getValue("fieldname"); but it returns nothing.
Even g_form.getDisplayBox("fieldname"); gives no value.
All other field values are getting returned in the client script except ref field.
What is alternative.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 04:29 AM
@Snehal13 getDisplayBox() method syntax is depends on where you are using it, whether its classic UI or Service Portal. I tested below in PDI and it works fine. Also check your field backend name.
alert(g_form.getDisplayBox('cost_center').value); //--classic UI
alert(g_form.getDisplayValue('cost_center')); //--service portal
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 07:24 AM
I forgot to add- This is a workspace client script.
var value = g_form.getDisplayBox('fieldName').value; isnt working.
var value = g_form.getValue("fieldname"); also not working to retrieve value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 04:52 AM
You may try using getReference or GlideAjax.
sample code snippet:
vfunction onChange(control, oldValue, newValue, isLoading) {
g_form.getReference('caller_id', doAlert); // doAlert is our callback function
}
function doAlert(caller) { // reference is passed into callback as first arguments
if (caller.getValue('vip') == 'true') {
alert('Caller is a VIP!');
}
}