The CreatorCon Call for Content is officially open! Get started here.

I want to hide a button (UI Action) from users with a certain role

ewilks
Giga Expert

In the condition of the UI Action, I currently have the following code: current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList()

 

I would like to keep anyone who has the role of auditor from seeing this UI Action (button), so I added: && !gs.hasRole('auditor')

 

The entirety of the condition is now:   current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList() && !gs.hasRole('auditor')

 

I assumed that this would mean, that for a user to see this, they would have to not have the role of auditor.   But when I impersonate an auditor, I still see the button.

 

What am I doing wrong?

16 REPLIES 16

Vaibhav,


Have you tried something like this?


( (!gs.hasRole('asset_viewer') && !gs.hasRole('role_2') && !gs.hasRole('role_3') )|| gs.hasRole('admin'))



In this case it will be hidden from roles; asset_viewer, role_2, role_3.   Notice the parenthesis around the roles that you want to block.


Hi Eric,



Thanks for the quick reply.


But issue i am having is,I just want to hide button from asset_viewer role.Other roles can see it.I can't put each and every role in that condition.


And i am not able to understand why this "!gs.hasRole('asset_viewer')" condition is not working for me. It should work.