
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 01:37 PM
Hello,
I have a catalog item that has a Select Box variable. One of the options needs to be unavailable if the user does NOT have a specific role.
For people that DO have the role the form seems to be working normally with all options available, however when testing with a user account that does NOT have the role the entire bottom half of the form is missing, so obviously there's some javascript bug.
Here is the code I'm using, can you tell me what I'm missing here? Still a novice at scripting.
function onLoad() {
//Remove IIO Budget option if user does NOT have iio_budget_user role
if (g_user.hasRole('iio_budget_user')){
return;
}
else g_form.removeOption('select_funding_source', 'IIO Funded');
}
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 01:46 PM
Hi, perhaps the return; is stopping the form from loading.
How about trying a simplified version?
if (!g_user.hasRole('iio_budget_user')) {
g_form.removeOption('select_funding_source', 'IIO Funded');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 01:46 PM
Hi, perhaps the return; is stopping the form from loading.
How about trying a simplified version?
if (!g_user.hasRole('iio_budget_user')) {
g_form.removeOption('select_funding_source', 'IIO Funded');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020 10:37 AM
Seems like this would work, but for some reason it's doing the same thing, it's not showing the bottom of the form where this variable exists.
The variable is inside of a variable set, here's the code just in case I've done something stupid:
function onLoad() {
//Remove IIO Budget option if user does NOT have iio_budget_user role
if (!g_user.hasRole('iio_budget_user')) {
g_form.removeOption('select_funding_source', 'IIO Funded');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020 10:49 AM
Sorry I found another issue that was causing the form to not load properly, your solution above works perfectly. Thank you!