Role Based Menu and HomeScreen in Mobile

Role Based Menu and HomeScreen in Mobile


I am trying to dynamically show or hide certain links in my mobile menu (using If blocks), and have a different home page for users of my app depending on their role. I currently have the following logic in the OnLoadComplete action of my Splash page (the CheckRoles action calls CheckTenantRole and CheckFormerTenantRole, where Tenant and Former Tenant are roles created in the Logic > Roles folder):

This seems to work sometimes, but I'm not sure whether the splash screen logic is always executed. As in, it seems that sometimes if the application is already loaded into memory(?) it just goes straight to the home screen.

I thought about adding this logic into the Login action, but users can use the app as the Anonymous role, so they would never hit this Login action.

Finally, I created a generic HomeScreen with a loading symbol, and in the OnRender event of that HomeScreen added logic similar to the above to redirect the user to the correct screen. HOWEVER, this for some reason kept overloading the personal environment for using too many resources and caused a 503 error (this was resolved by contacting support directly to restart the environment).

The Question

After all that pre-amble, my question is what is the best way to implement a role based menu and role based home screen in a mobile app?


Hi Russell,

I would say the best way is to:

  • Have in the OnInitialize of the HomeScreen the logic to redirect the user to right the Screen
  • In that logic do not call Server Actions. Use instead a Javascript statement to check the roles:
  • Do more or less the same in the Menu Block with If conditions to show or not the Menu Items
    • You will probably need one or more local variables to store the information about the menu item being shown or not.




Thanks José,

I have created a new HomeScreen called HomeScreenRedirector. In the OnInitialize event I created a javaScript node where i checked the following roles:

// check if the current user has the 'Tenant' role
$parameters.IsTenant = $public.Security.checkIfCurrentUserHasRole($roles.Tenant);

// check if the current user has the 'FormerTenant' role
$parameters.IsFormerTenant = $public.Security.checkIfCurrentUserHasRole($roles.FormerTenant);

Using an If Statement after this I was able to redirect to a new screen depending on the value of the output parameter - wonderful!

Is there also a way to do this for the Registered role though? When I added the code below I received the error that follows:

// check if the current user has the 'Registered' role
$parameters.IsRegistered = $public.Security.checkIfCurrentUserHasRole($roles.Registered);

Error: Invalid JavaScript : Unknown 'Registered' role used in 'JavaScript1'.

Hi Russel,

You can check if the GetUserId() is different from 0 (zero). If it is different then it has the Registered role.



Oh of course, José, I was so hung up on the javaScript I forgot about doing it a normal way. That's perfect, and seems to be working now, thank you so much for your help and speedy replies.