- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2016 08:12 AM
I have an onChange script I'd like to run on a catalog item but my script doesn't seem to be working. Any thoughts?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var type = g_form.getValue('employee_type');
if(type == 'Contractor' || type == 'Consultant'){
g_form.removeOption('company','92944b3937e4c280e96da6d2b3990ecf');
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017 11:25 AM
No I don't think that is possible. Since it is a reference field but you are just displaying it as a drop down menu. You need to use reference qualifier on this field. But I don't think you can dynamically remove the option yet not removing the record from the reference table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017 11:10 AM
Its a reference field to the company table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2016 09:23 AM
Make sure your variable/ field name "employee_type" is correct. Make sure you are using choice values not the choice labels.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var type = g_form.getValue('employee_type'); // make sure this is a correct variable/ field name
if(type == 'Contractor' || type == 'Consultant'){ // put the choice values not the choice labels
g_form.removeOption('company','92944b3937e4c280e96da6d2b3990ecf'); // put choice value in the second parameter
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017 11:11 AM
Thanks Abhinay. I double/triple checked everything and changed the company to the value but it's still not working. The company field is a reference to a table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017 11:16 AM
I have the following script working perfectly on the same form so I feel it's an issue with g_form.removeOption.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var type = g_form.getValue('employee_type');
if(type == 'Employee' || type == 'Intern'){
g_form.setValue('company','92944b3937e4c280e96da6d2b3990ecf');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017 11:17 AM
Is there a way I can say if employee or intern set value otherwise hide this company in the script that is working?