- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 06:32 AM
I'm having issues to get the display values of two fields in a client script.
g_form.getDisplayValue('field_name') will return the number of the incident and not the actual display value of the field.
The fields I need the display values for is State (state) and Configuration Item (cmdb_ci).
From what I read in other threads you should use
g_form.getDisplayBox('field_name').value;
When I try this I get an error instead on the form when the Client Script is triggered
The code I'm using in the onChange client script is the following
var state = g_form.getDisplayBox('state').value;
alert(state);
The alert won't show, only the above error is displayed.
Any ideas what I could do to get the Display Value of the state field?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 07:21 AM
Did you try this?
var u_stateValue = g_form.getValue('state');
var u_stateLabel = g_form.getOption('state',u_stateValue).text;
PS - Please mark Helpful, Like, or Correct Answer if applicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 06:57 AM
Hey Fredrik,
I tested this on my instances, Helsinki Patch 2 & Geneva Patch6-Hotfix2, and I'm not seeing the error you are referring to. I believe what you are trying is working correctly.
- g_form.getDisplayBox('field_name').value;
The error is most likely caused by a different field. Look at state, as this isn't a reference field.
Do you mind sharing your client script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 07:04 AM
For the choice list, I believe you're going to make a call to the server on this one to get the display value. Sad, when the display value is RIGHT THERE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 07:06 AM
Thanks for the info, there were actually no error with the reference field (cmdb_ci). it's the value from the state field causing trouble
This is the script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Build up text
var text = '';
var num = g_form.getValue('number');
var title = g_form.getValue('short_description');
var state = g_form.getValue('state');
var impacted = g_form.getDisplayBox('cmdb_ci').value;
var start = g_form.getValue('work_start');
if (newValue == 'true') {
text = num + '\n' + impacted + ' - ' + title + '\nStart Time: ' + start + '\nFor more information, and update kindly check your email';
g_form.setValue('u_text', text);
}
}
So the only thing not working is to get the display value from the state field which obviously is a choice field and nothing else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 07:09 AM
Hi Brett,
This issue is caused when the field name provided in the function not present on the form. Either 'state' or cmdb_ci not available on the form. Right click on the field labels and verify backend names of the fields.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 07:10 AM
The field names are correct. I can put the same client script on state and it does the same error. g_form.getDisplayBox('fieldname').value works best for reference fields. It does not like choice fields.