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
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.
ThanksTousif
Hi Muqthar Beldar,
Here is the sample File. Kindly check it. Still not getting a solution. Please share the OML file.
Thanks,
Ramesh
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
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
Okay,
Alright, To check this on a redirect of a user you do not have to do anything extraJust 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 & RegrdsTousif Khan
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
I have updated my Comment please check. @Muqthar Beldar