Using User Role Checks for Conditional Visibility in UI Elements

Hello! I'm encountering issues with user roles. I need to configure a button to be visible only if the current user is the owner of the object or if the user has an admin role. Is this achievable using XPath alone, or do I need to consider other solutions? Im using Mendix 10.7.0.  
3 answers

Hi Felipe,

In this situation you can put button inside a dataview with source as a microflow and inside the microflow check if user is having admin role or he is the system owner , if any of the  condition meets return current user account entity if not return empty object.

After this you get current object in context of button visibility and put this condition that the  button will be only visible when $currentObject !=empty

Hope this helps!



You would accomplish the UserRole constraint using the section highlighted below:



Hope that helps,



Add to buttons to the page. One with condition on owner, one on condition of module role.

In the case that admins can also be the owner of the object, set for the button with the owner condition also the module role constraint. But exactly the opposite so Admin WON't see the button. This to avoid 2 buttons for Admins with ownership