Tenant Entity Access

Hello, I’m struggling to make tenant entity access work in my new app. I’m trying to create an App where attributes of an entity (called ‘FMO’) are filled in forms. These entities get commited  and are then viewed in a data list.  I used the module ‘Multi Tenant Administration’ (https://appstore.home.mendix.com/link/app/80498/) for User Administration. My aim is to only see the entities, that were created in the own tenant of the user. Other FMO-objects of other tenants are not allowed to be seen! I associated my entity to the tenant entity and I added a XPath-Constraint in the access rules of the entity ( [MyFirstModule.FMO_Tenant/MultiTenantAdministration.Tenant/MultiTenantAdministration.TenantUser_Tenant = '[%CurrentUser%]'] ), as it is told in the docs (https://docs.mendix.com/howto/security/set-up-your-first-multi-tenant-app) . However, when I use my app and create an entity as a tenant user I can’t see it afterwards in my list view (which has the data source FMO from database).  How can I fix this? Is my XPath-Constraint wrong or do I have to something additionally? I thought of selecting a XPath-Constraint as the data source for my list view, but why should it be wrong to set the data source as the entity, when the view is already restricted through the XPath-Constraint access rule in my entity? Thank you in advance for your help!
2 answers

When creating the new entity are you associating it with the respective tenant?

The association needs to be made explicitly even if the grid has a restriction with it.

Hope this helps


You need to set the association to the Tenant in an After Create event of FMO.

  1. Goto Entity FMO/Event
  2. New, Create, After.. Give the microflow a name.
  3. Retrieve the first Tenant from database ( TenantUser_Tenant = '[%CurrentUser%]'] )
  4. Change the FMO object (no commit) FMO_Tenant = object from previous step (3).