How to Restrict Menu Bar Links Based on Roles
Question
Application Type
Reactive

Hello all,

I'm trying to restrict a link which is in Menu Bar from particular roles, but not able to check roles using check roles function as they're not available here.

below is my menu bar link


And I find roles to use this in a if condition

Solution

Hi Jeevan Sai,

you can use the Javascript API  to perform the client side role validation by using the checkIfCurrentUserHasRole function. 

It returns true, if the current user has the given role, false otherwise.

Based on this you can give the condition.

Hope it helps!

Regards,

Ellakkiya.S

Hi thanks for the response, I used Data Action to resolve my issue, I'll try using JavaScript API too


Thanks,

Sai

Tried using this client side method and it's working too .


Thanks.

Solution

Hello @Jeevan Sai 

Add an Action[Fetch data from other sources] in Menu bar

, inside that action you can do like


Finally assign the Boolean variable to the links visible property


This might solve your Isuue


Thanks,

Sandeep.

Solution

Hi Jeevan Sai,

you can use the Javascript API  to perform the client side role validation by using the checkIfCurrentUserHasRole function. 

It returns true, if the current user has the given role, false otherwise.

Based on this you can give the condition.

Hope it helps!

Regards,

Ellakkiya.S

Hi thanks for the response, I used Data Action to resolve my issue, I'll try using JavaScript API too


Thanks,

Sai

Tried using this client side method and it's working too .


Thanks.

Possibly you will need to use a server action or data action to check the role.

Please read this thread, if it can help you. If not, share your oml if you can and I can have a look.

https://www.outsystems.com/forums/discussion/29777/cannot-use-check-roles-function/

https://www.outsystems.com/forums/discussion/32252/menu-access/


Kind regards,

Márcio

Solution

Hello @Jeevan Sai 

Add an Action[Fetch data from other sources] in Menu bar

, inside that action you can do like


Finally assign the Boolean variable to the links visible property


This might solve your Isuue


Thanks,

Sandeep.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.