removing options in a dropdown
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 10:54 AM
Hey all,
I cant work out why my scripts are not working. i need to do this this on two different tables/locations
1. Catalog item. I need to remove an option dependent on the answer to the previous question. my script is below, I have changed this several times but cant work out what is wong with my script. I guess the first question is can this be done on a catalog item?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var ecms_mob = g_form.getValue('ecms_mobile');
if (ecms_mob =='No'){
g_form.removeOption('device_type', 'Smartphone');
}
}
2. Removing resolved as an option based on an incident being a new ticket.
function onLoad() {
if (g_form.isNewRecord())
g_form.removeOption("state", 6);
}
I have been going around in circles on these, if someone could point out the problem it would be most appreciated.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 11:22 AM
On the first, I assume the onChange is on change of ecms_mob?
the script should then be
if(newValue == 'No'){
g_form.removeOption('device_type', 'Smartphone');
}
With no variable declaration.
The second looks right to me. Maybe put brackets around it just in case?
function onLoad() {
if (g_form.isNewRecord()){
g_form.removeOption("state", 6);
}
}
That is how the system does it OOB on Client Script Validate New Table Name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 11:38 AM
Hey Mike,
So the full script should be as per below? if so its still not removing the option if i change ECMS mob from -none- to No
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(newValue == 'No'){
g_form.removeOption('device_type', 'Smartphone');
}
}
The change to the second script works. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 11:54 AM
It looks right to me. Only thing I can think is to check to ensure the value and field are correct. Let me mock something up in my developer instance and see if I can replicate the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 12:00 PM
Thanks Mike, most appreciated
Just to double check, as this is a catalog item should it work in the same way with the same method