- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 05:53 AM
Hello all,
I am looking for a way, if there's any, to have the options in a select box be selectable by role.
As shown in he attachment, I would like for only users with certain role OR group membership to ONLY be able to select (or see) the Purchase option.
Any help or suggestion would be appreciated.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 06:34 AM
Hey,
it should be like this
function onLoad() {
if (!g_user.hasRole('rtls_purchase_view')) {
g_form.removeOption('type_of_purchase_replacement',"Purchase");
}
}
, also remove <>, those are just to show where you have to place the fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 05:59 AM - edited 07-15-2024 06:00 AM
Hi,
What you can do is, Check if the user has the role, if not then remove Purchase form the dropdown.
Something like
if (!g_user.hasRole('<ROLE NAME>')) {
g_form.removeOption('<FIELD NAME>',"<CHOICE VALUE>");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 06:12 AM
Thanks Anurag,
Please pardon my obvious lack of understanding, I did this and here's what I got.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 06:18 AM
Hi @Hola Ola
You don't need to remove function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 06:30 AM
Hi @Hola Ola,
You need to wrap the if statement within an onLoad function as follows:
function onLoad() {
if (!g_user.hasRoleExactly('the_role_name_required')) {
g_form.removeOption('the_field_name', 'the_value_name_to_remove');
}
}
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie