g_form.getValue() return the value and not the name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2018 10:51 AM
Below is the code i use for the record producer. I need to get the Name but it returns the value.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert ('load');
var choice = g_form.getValue('pay_discrepancy_type');
alert (choice);
g_form.setValue('pay_dependancy_inquiry', 'Please ' + choice + ' attach');
}
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2018 10:56 AM
I would try something like this:
var fieldName = 'pay_discrepancy_type';
var fieldValue = g_form.getValue(fieldName);
var choice = g_form.getOption(fieldName, fieldValue).text;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2018 11:16 AM
Thank you for responding Brad,
Getting an error "There is a JavaScript error in your browser console"
The pay_discrepancy_type is mapped to a field. Could this be the reason?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2018 11:23 AM
Could you post the script whole you're using (incorporating my suggestion) and the error from the console? Is the variable you're running this on a select box or a reference variable displayed as a choice list?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2018 11:38 AM
It is a multiple choice field mapped to a field. Below is the script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// alert ('load');
var fieldName = 'pay_discrepancy_type';
var fieldValue = g_form.getValue(fieldName);
var choice = g_form.getOption(fieldName, fieldValue).text;
// alert (choice);
g_form.setValue('pay_dependancy_inquiry', 'Please ' + choice + ' attach');
}
Below are the field and error screenshots