What exactly does a unique index do on a multi-tenant entity?

When you define a unique index on an attribute of an entity the platform will ensure the values of the attribute will be unique and raise an exception when storing a duplicate value for that attribute is attempted.

Now, when one defines an entity to be multi-tenant, is uniqueness ensured WITHIN a single Tenant ONLY, or is uniqueness ensured OVER ALL Tenants?

For example, suppose you have defined an entity Site with a unique index on the single attribute Name. The entity is set to be multi-tenant and you have created 'Tenant 1' and 'Tenant 2'. Someone from 'Tenant 1' creates a Site  record with Name = 'Example 1'. When 'Tenant 1' then tries to create a new Site record with Name = 'Example 1' I would expect (and want) a duplicate Name exception. But what if the other tenant, 'Tenant 2', wants to create a record with Name = 'Example 1', will the platform allow this (as I would hope) or also generate a duplicate Name exception?

Anyone with practical multi-tenant experience that can answer this question?


Hi Frans, 

We have done a little experience and the conclude that: 

- If the entity is multitenant and the "TenantId" is hidden - the platform allows the duplicates if in different tenants

- if the entity is multitenant and the "TenantId" is shown - the platform don't allow, unless the "TenantId" field is also add to the index




Thanks Graça :-)