- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 10:25 AM
I'm trying to set the default value in a choice list to 'New Hire' based up on a previous selection in another field, but my script does not work:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var newHire = g_form.getValue('request_for_new_hire');
if(newHire == 'Yes, and the start date is contingent/not yet determined'){
g_form.setValue('employee_type', 'New Hire');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 10:51 AM
Finally got it working by updating the field value, and setValue:
if(newHire == 'yes_contingent'){
g_form.setValue('employee_type', 'new_hire', 'New Hire');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 10:28 AM
Hello,
Are you setting the actual value for the employee type choice label? It is always best practice to keep your values in lower cases and with underscores.
g_form.setValue('employee_type', 'new_hire');
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 10:34 AM
'New Hire' is one of the choice options for the 'Employee Type' variable. The actual value is 'new_hire', and I've tried changing to this but not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 10:40 AM
Check the actual value of request_for_new_hire. Yes, and the start date is contingent/not yet determined could be a display value, but the actual value could be different. Same applies for employee_type.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 10:51 AM
Finally got it working by updating the field value, and setValue:
if(newHire == 'yes_contingent'){
g_form.setValue('employee_type', 'new_hire', 'New Hire');