How can I limit my data grid to an attribute associated to Administration.Account and $currentUser

I have an entity (company) associated to Administration.Account (which might not be a good idea?) I have a datagrid where I want to list only objects created by (owned) by users associated to the same company as $currentUser, but I'm struggling to pull it off. Any thoughts? Thanks Good feedback, but a bit of clarification. I have the owner attribute saved. I don't think I can limit this at the data model level. I have offerings where on a specific (seller) page my datagrid will be limited to offerings that have been created by users associated to the same company as $currentUser. On another (buyer) page, there is a datagrid which contains all the offers which are available for purchase, which contains all the offers created by users not associated with $currentUser's company. Thanks for your thoughts.
2 answers

Sounds like you want to limit the grid, but not based on security. No problem, here's what you do:

  • In your data grid properties, go to Data Source
  • Set the data source to XPath
  • (Re)select your entity
  • In the XPath contraint field, enter XPath like this (you'll need to modify for your exact module/entity/association names:

[System.owner/Administration.Account/Administration.Account_Company/YourModule.Company/Administration.Account_Company = '[%CurrentUser%]']

This path limits your grid to only items that have an owner with a company that is also associated to the current account.


Mendix already can keep track of the creator (owner) and last change details of an object. No need to create an association for that. Double click your entity on your domain model and turn on (at least) the Store owner checkbox

Create or change an access rule for your entity and switch to the XPath constraint tab. Click the owner button and Mendix will add the constraint.

Check here for more info: