g_form.removeOption not working as expected on onLoad client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 01:39 AM
Hi, I am trying to hide 2 question choice options that are not required temporariliy.
I am trying to use the g_form.removeOption but I cannot get this to work. I am not sure if this is because of what I am doing...
I am using the below... where u_access_type is the question field and loss and profit are the value of the option.
function onLoad() {
g_form.removeOption('u_access_type', 'loss');
g_form.removeOption('u_access_type', 'profit');
}
Any help appreciated!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 02:29 AM
Hi,
follow link: client-scripts-scripting/removing-disabling-choice-list-options
Please: Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 02:31 AM
What happens when you run the same via javascript executor??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 02:43 AM
hi
I m given one Example!
//Remove the 'Closed' state option if the user is not an admin and state is not 'Closed'
function onLoad() {
var isAdmin = g_user.hasRole('admin');
var state = g_form.getValue('state');
if (!isAdmin && (state != 7)){
//alert('Current user is not an admin');
g_form.removeOption('state', '7');
}
}
Thanks,
Rahul Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 02:47 AM
You should only remove the option if it is not the currently-selected option when the form loads.