- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2016 02:08 PM
I have a request to populate a field based on the answer to multiple fields. The script submits without errors but it is showing an error on the catalog item. Below I have included the script and error. Any help on what I'm not seeing would be great. Thank you!
SCRIPT:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == 'registered') {
return;
}
//Type appropriate comment here, and begin script below
}function onChange(control, oldValue, newValue, isLoading)
{
var title = g_form.getValue('job_title');
var location = g_form.getValue('location');
if ('advisor' == 'Yes') {
g_form.setValue('compliance_group', "Yes");
}
else if (registered == 'Yes'){
g_form.setValue('compliance_group', "registered");
}
else if (registered == "No" && title == "Senior Vice President" || "Managing Director"){
g_form.setValue('compliance_group',"leadership");
}
else if (location == "Des Moines, IA") {
g_form.setValue('compliance_group',"des_moines");
} else {
g_form.setValue('compliance_group',"non_registered");
}
}
ERROR:
onChange script error: ReferenceError: registered is not defined function h_63033715375a22006ca9d5c543990e4b(control, oldValue, newValue, isLoading) { var title = g_form.getValue('job_title'); var location = g_form.getValue('location'); if ('advisor' == 'Yes') { g_form.setValue('compliance_group', "Yes"); } else if (registered == 'Yes'){ g_form.setValue('compliance_group', "registered"); } else if (registered == "No" && title == "Senior Vice President" || "Managing Director"){ g_form.setValue('compliance_group',"leadership"); } else if (location == "Des Moines, IA") { g_form.setValue('compliance_group',"des_moines"); } else { g_form.setValue('compliance_group',"non_registered"); } }
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 08:01 AM
Since, the same client script is supposed to trigger onchange of 2 or more variables, you should use 'onSubmit' client script as:
function onSubmit() {
//Type appropriate comment here, and begin script below
var title = g_form.getValue('job_title');
var location = g_form.getValue('location');
if (g_form.getValue('advisor') == 'Yes')
g_form.setValue('compliance_group', "Advisors");
else if (g_form.getValue('registered') == 'Yes')
g_form.setValue('compliance_group', "Registered");
else if (title == "Senior Vice President" || title == "Managing Director")
g_form.setValue('compliance_group',"Leadership");
else if (location == "Des Moines, IA")
g_form.setValue('compliance_group',"Des Moines, IA");
else
g_form.setValue('compliance_group',"Non registered");
}
Let me know, if you face any problem further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 08:24 AM
This is working wonderfully. Guess I need to head back to some scripting classes. Thank you so much for your help!!!!