- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 04:18 PM
Have variable in my record producer with Field name, u_testchoice, which is a select box with values ("none", "value1","value2",and "value3").
When the user sets that u_testchoice field value to "value2", I want my client script to set the record producer field named u_teststring to "Yahoo".
Here is my code, which seems to do nothing.
function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == ' ') {
return;
}
//Type appropriate comment here, and begin script below
if (producer.u_testchoice == 'value2'){
g_form.setValue('u_teststring','Yahoo'); }
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 09:20 PM
It does work for me
//tested
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert('load');
g_form.clearValue('test_string');
var choice = g_form.getValue('u_testchoice');
alert(choice);
if (choice == 'value_2') // value_2 is the value of the choice
{
alert('inside');
g_form.setValue('test_string','Yahoo');
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 08:55 PM
Hi Jim,
I tried adding your alert line but saw nothing. Where would I expect to see the output?
I also added this to the Record Producer script and was able to confirm, after submission, that the value in u_testchoice is in fact 'value2'.
message += ' Variable: ';
message += producer.u_testchoice;
gs.addInfoMessage(message);
Thank you for sharing your insight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 09:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 09:42 PM
Had nothing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 08:34 PM
Hi Glenn,
I might have found where you are stuck.
The getValue() returns the backend value of a choice field
Eg: I have question choices like below
Name | Value |
---|---|
Value1 | 1 |
Value2 | 2 |
So, here the getValue() will return 1 and 2 and not value 1 and value 2.
So, I feel your code is right just check the values you are checking in the if condition.
Also, do a check on the field names are correct
function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == '') {
return;
}
var choice = g_form.getValue('u_testchoice');
if (choice == '2') { // This should be the backend value always
g_form.setValue('u_teststring','Yahoo');
}
}
Note: Always add alert between lines to check the values being passed in the variables for troubleshooting.
Please hit like or mark helpful if found appropriate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 09:03 PM
Hi arka,
I liked the sound of this... seemed plausible. Except for the fact that I'm not sure where to look for the alert output, which I tried from Jim's comment, I was able to confirm the literal value of my u_testchoice is 'value2'. Now, I'm wondering if the values in a choice field are available to the script before submission of the form?