- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2019 05:29 AM
Hello,
I am working on a Catalog Client script that will automatically select a choice from a list select box when a separate yes/no variable is toggled to "Yes" I used an alert to verify that my IF statement is working, and it seems to be working fine. The issue I am having is with the g_form.setValue(). I have tried using the text option that is in the choice list and the value and have had no luck with automatically changing the choice selection.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (g_form.getDisplayValue('u_hasData') == "yes")
{
alert(g_form.getDisplayValue('u_hasData'));
g_form.setValue('pre_disposal', 'IT');
}
}
any suggestions?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2019 05:37 AM
Try:
if (g_form.getValue('u_hasData') == 'Yes')
or
if (g_form.getValue('u_hasData') == 'yes')
I forget which one works
and for this:
g_form.setValue('pre_disposal', 'IT');
Is IT...the value of an eligible select box option? Like does it already exist? If so...it should work, if not, and you're trying to force it in there, see above post from another user on how to add it.
You'd need to make sure that for the variable select box 'pre_disposal' that it has a select box choice of IT as the value, not the name, but value.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2019 05:35 AM
are you setting the value in select box type variable?
if yest try with g_form.addOption()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2019 05:37 AM
Try:
if (g_form.getValue('u_hasData') == 'Yes')
or
if (g_form.getValue('u_hasData') == 'yes')
I forget which one works
and for this:
g_form.setValue('pre_disposal', 'IT');
Is IT...the value of an eligible select box option? Like does it already exist? If so...it should work, if not, and you're trying to force it in there, see above post from another user on how to add it.
You'd need to make sure that for the variable select box 'pre_disposal' that it has a select box choice of IT as the value, not the name, but value.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2019 06:07 AM
"You'd need to make sure that for the variable select box 'pre_disposal' that it has a select box choice of IT as the value, not the name, but value."
That did it. I had set the value to a numeric value and tired using that before by using
g_form.setValue('pre_disposal', '5')
and had no luck.
Changing it to the value of the IT option to "IT" and using
g_form.setValue('pre_disposal', 'IT')
Worked like a charm.
Thank you sir.