Populate data grid based on user role

Lets say I have a list of objects with 2 prepopulated fields (Name & Role)  ex: [object1,admin], [object2,user], [object3,admin]   Assuming I know the role of the person logging in (in this case the user logs in with role “admin”)   How do I retrieve objects to display on a data grid by using xpath or database as source that match only the role admin? my data grid should display object1 & object 3 only.   I cannot use a microflow. I am trying to display too many objects and one of the requirements is to use a search function. A microflow makes the interface very slow and if I use pagination then I can not display a search box and search through all the objects.   
1 answers

Hi Alex,

question is, what defines that object 1 & 3 should be displayed for an admin and 2 for a user?

Its either

  1. A specific value, for example a order status “Draft” for a user and “Submitted” for an admin.
    In this case put an 2 access rules on the entity. 1 for user with XPath constraint [Status = ‘Draft’] a 1 for admin with XPath constraint [Status = ‘Submitted’]
  2. A specific relation; either owner or a reference to account/User
    In this case put again 2 access rules but instead on constraining on value, use the path from queried entity to account. If you don’t have such reference, you need one ;-)

As you see, I put a constraint on access rule. Which results that the admin never will be able to see the draft and the user never the submitted orders.

If you need is that it is displayed on a specific list, but other status should be available on a different location of the app; then create two pages, one for admin and User with constraint set on List datasource. OR add 2 lists on the same page with different constraints and make one visible for Admin and the other for User.


PRO TIP: take the online Rapid developer learning path first before trying it yourself. https://academy.mendix.com/link/path/31/Become-a-Rapid-Developer 

We men should learn to read the guide before using the product ;-)