
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 06:30 AM
Hello SN Developers!
I have an onLoad event that is supposed to hide an option on a field if the user does not have a specific role (and conversely, add the option if they do). I know the code is firing correctly because of the alerts I put in but the option is not working as expected.
Here's my code:
Any thoughts/suggestions?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 08:06 AM
@Maria20, yes thats actually the issue. The removeOption function does not work for reference fields. There you will have to use „reference qualifiers“ or ACL rules.
Greetings,
Sören

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 06:56 AM
Hello @Maria20,
in the function "removeOption", you have to provide the field name and then the option value.
Could it be that you are currently using the option Text instead of the Option Value (highlighted in yellow in th following Screenshot).
I reproduced your situation and it is working for me:
Furthermore, I would suggest to either hide or remove the option depending on the role. You dont have to do both. This you would only need if the user changes his role between two loads, which would probably not happen. In my experience adding an option can sometimes lead to unexpected behavior, so I would suggest just removing an option if the user does not have the mentioned role.
I hope this helped!
Greetings,
Sören

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 07:23 AM
Hello,
What Soren said is correct, you can just add removeOption and no need to add Addoption again.
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 07:57 AM
Hello Musab,
Maybe my problem is that my "application" field is not a choice list but a reference-type field?!?!
Maria.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 08:06 AM
@Maria20, yes thats actually the issue. The removeOption function does not work for reference fields. There you will have to use „reference qualifiers“ or ACL rules.
Greetings,
Sören