- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2017 10:21 AM
I have an OnLoad client script to set a choice list field and then set the actual value of the field.
The choices are dynamic and are first looked up (when another reference field is entered) and then stored in a field to feed the choice list.
The choice values are being correctly returned and the options in the choice list are being set. However, if a value in the field exists, when reloading the form, only the value is shown, not the display value:
Here's my client script:
function onLoad() {
//Type appropriate comment here, and begin script below
//Build Coverage Item Description Code choice list
var covCodes = g_form.getValue('coverage_code_options');
var covNum;
var currValue = g_form.getValue('coverage_item_description_code');
g_form.clearValue('coverage_item_description_code');
alert('currValue - ' + currValue);
if(covCodes == ''){
return;
}
var codeChoices = covCodes.split(',');
var i = 0;
for(i = 0; i < codeChoices.length; i++) {
covNum = codeChoices[i].split(' - ');
g_form.addOption('coverage_item_description_code', covNum[0], codeChoices[i].toString(), covNum[0]);
if(currValue == covNum[0]){
alert("into IF - " + covNum[0] + " - " + codeChoices[i].toString());
g_form.setValue('coverage_item_description_code', covNum[0], codeChoices[i].toString());
}
}
}
The alerts show me that I AM getting the correct values (5 and 5 - TOOLS in my example) but I can't get the field to show "5 - TOOLS" That should, as far as I can tell, be what line 27 does. What am I doing wrong?
TIA!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2017 10:35 AM
Hi,
Can you try updating line 29 as below
g_form.setValue('coverage_item_description_code', codeChoices[i].toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2017 11:11 AM
Further, please use g_form.clearOption() instead of clearValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2017 11:18 AM
I've tried g_form.clearOptions('coverage_item_description_code'); and it's removing the number only but leaving a duplicate of the '5 - TOOLS' choice.
I think that will be sufficient but it's still not totally correct.