213
Views
7
Comments
Role based Screen while login

Hi,

I am new to OutSystems world, I am trying a simple Mobile application to display different screens based on  the role like Manager and Employee.

Unable to get the role details in the JavaScript Node implementation


JavaScript code : 


$parameters.IsManager = $public.Security.checkIfCurrentUserHasRole($roles.Manager)

I am always getting the IsManager as false, even though the User is having a Manager Role

Thanks in Advance for the help

Regards

Muqthar


Screenshot (15).png
2023-10-21 19-42-11
Tousif Khan
Champion

Hello

Have you already defined the Role in a Logic tab under Roles Section.


Once this is done Create an OnInitialise action and add JavaScript to it.

I am attaching an Oml hope it helps.

Make sure you have created a user and assigned a role to it.

Thanks
Tousif

Sample_POCS_CheckRoleOffline_Sample.oml
2025-10-18 11-13-53
Ramesh subramanian

Hi Muqthar Beldar,

Here is the sample File. Kindly check it. Still not getting a solution. Please share the OML file.


Thanks,

Ramesh

CheckRoleJSMobile.oml
2022-07-03 17-24-08
Sourabh sharma

Hi Muqthar Beldar,

welcome to outsystems family!! here you have seen how to use and check the role using JS. but outsystems has given itself very beautiful functionality  to check the role using data action .. here you can read ..Read "How to check role "


Here I have made the Application to play with Roles on screen .Try this .also i have given the Oml to see the code!!

Hope it wii help you 











RoleBaseScreen_UI.oml
UserImage.jpg
Muqthar Beldar

Hi Tousif, Ramesh and Sourabh,

Thank you so much for your responses, tried the two approaches shared by Tousif and Ramesh, still no luck, my requirement is redirecting to the role based screens for e.g., if Logged in User having manager role then Manager screen to show otherwise employee to show.

Added users in the app with both Manager and employee roles.

In the meantime will try the Data Action option

For your reference attaching the oml file for reference

Thanks

Muqthar

Test4.oap
2023-10-21 19-42-11
Tousif Khan
Champion

Okay,

Alright, To check this on a redirect of a user you do not have to do anything extra

Just check the role On a screen, On a Screen Property

Another way if you want to do this on an OnInitialize action you just need an If Node where you will check whether you have a role or not, Of you have a role you will be redirected otherwise you will be redirected to Incalid Screen

For more Details On redirection you car refer to these solutions:

I hope this help 

Thanks & Regrds
Tousif Khan

UserImage.jpg
Muqthar Beldar

Thank you for your response Tauseef, but even after specifying the roles on the screens also re-direction not happening. Is it something to do with the Role permissions on Splash screen. As in my sample app (oml shared in my previous thread) After login it's displaying the same login screen again and again

2023-10-21 19-42-11
Tousif Khan
Champion
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.