Can an existing entity, which has referential integrity constraint, be converted into a multi tenant entity? My entity is referenced by several entities, is it feasible and possible to change the multi tenancy behavior without breaking the code? If yes, what is the best way to achieve this? 

Hi Mishika,

yes you can whitout any data lose. once you convert your entity to multi tenant there is only one entity attribue add tenantid to all corrosponding data and assign defalut value of tenant .

If you want change existing entity to multi tenant there a way double click on entity and go to advance tab and click on yes - is multi tenant 


May be somewhere it will break code, like Advance sql.


Hope this will help you.

Ragards

Rahul Sahu

Hi Mihika,

Multi-tenancy is a very powerful feature of Outsystems and it is not just limited to making your entities but there are other elements like users,Site properties , Timers and BPT process can also be set to  multi tenant and hence it is very importnat to first understand how multi-tenancy works in Outysytems.

You can also have non multi-tenant and multi-tenant entities in the same application but while executing your queries you need to make sure that proper filters are being used .

Please go through this link for more understanding.

https://success.outsystems.com/Support/Enterprise_Customers/Maintenance_and_Operations/How_to_Build_a_Multi-tenant_Application

Any additional information will also help me to provide better solution for your quesries.


Regards,

-PJ-

Thanks Rahul and Pramod,

I have other multi tenant entities in my application which are working as expected. This entity (Entity A) was originally a single tenant entity, The data from this entity is stored in other multi-tenant entity (Entity B) as reference, If I convert A to multi-tenant the data stored in B will be pointing to a non existent data for the other Tenant. How do I circumvent this?

Hi Mishika,

I tried reproducing the same scenario at my end and what is happening here is , changing entity to multi-tenant will add the Tenant_id column to your entity and insert the value of default tenant_id (User tenant ) in that column. I also observed the data which was inserted as foreign key to other multi-tenant remain same there in that table .

Other option i see to have your data consistence , if you are doing it in development environment cleanup all the data from you entities and than change and publish your entities again.

I am trying some more scenario and will share the results with you soon.

Regards,

-PJ-

Hi Mishika ,

Here is some more explanation with example.

You have two Tenants (User - Default Tenant - id:20) and (TestTenant- Your Tenant- id:21) 

Now you have two entities Entity A and Entity B like shown below (have populated some data as well for example)

Entity  A
Column1-PrimaryKeyColumn2Column3
101Data 1Test 1
102Data 2Test 2
103Data 3Test 3
104Data 4Test 4


Entity B (Multitenant)
Tenant_IdColumn1Column2Column3-Foreignkey-Entity  A
21Test DataTest Data101
21Test DataTest Data102
21Test DataTest Data103
21Test DataTest Data104


In this situation the value of the Column3 in Entity B will be visible through Entity A by putting a join condition.

Now if we change the first entity to Multi-Tenant the data in the table will be updated like below.

Entity  A
Tenant_IDColumn1-PrimaryKeyColumn2Column3
20 (Default Tenant)101Data 1Test 1
20 (Default Tenant)102Data 2Test 2
20 (Default Tenant)103Data 3Test 3
20 (Default Tenant)104Data 4Test 4


And after this change if you run the existing query on Entity B where you have data from other tenant , the data fro Column3-ForeignKeyFromA  value will not be visible as the tenant id is different.


Regards,

-PJ-

Pramod Jain wrote:

Hi Mishika ,

Here is some more explanation with example.

You have two Tenants (User - Default Tenant - id:20) and (TestTenant- Your Tenant- id:21) 

Now you have two entities Entity A and Entity B like shown below (have populated some data as well for example)

Entity  A
Column1-PrimaryKeyColumn2Column3
101Data 1Test 1
102Data 2Test 2
103Data 3Test 3
104Data 4Test 4


Entity B (Multitenant)
Tenant_IdColumn1Column2Column3-Foreignkey-Entity  A
21Test DataTest Data101
21Test DataTest Data102
21Test DataTest Data103
21Test DataTest Data104


In this situation the value of the Column3 in Entity B will be visible through Entity A by putting a join condition.

Now if we change the first entity to Multi-Tenant the data in the table will be updated like below.

Entity  A
Tenant_IDColumn1-PrimaryKeyColumn2Column3
20 (Default Tenant)101Data 1Test 1
20 (Default Tenant)102Data 2Test 2
20 (Default Tenant)103Data 3Test 3
20 (Default Tenant)104Data 4Test 4


And after this change if you run the existing query on Entity B where you have data from other tenant , the data fro Column3-ForeignKeyFromA  value will not be visible as the tenant id is different.


Regards,

-PJ-

Thanks Pramod.

I know you are one of the best person in community to explain and guide on multi tenancy.  Thanks for your time for guiding and explaining.

My ques are:

1. If there are multiple tenant, which one will work/selected as default tenant.

2. Should we enter data (may be same data we need to insert) for all other tenant to get proper results in entity A. Via backend or bootstrap.

@Mishika,

Do we have database access and is it on premises or on os cloud.

Thanks,

Saifee


Hi Abdul ,

Thanks for the nice compliments ...i just always try to help community 

let me try to answer your questions.

1. The selection of tenant done based on the users tenant after the users logged in successfully , now there are scenarios where the same userid\password you have for the same user in multiple tenants in that case depends upon the query result any tenant can be his default tenants.

The other option in such cases is on the login screen as user enters the username show a drop-down with all the tenants where he got crated as a user and than login to the same tenant.

One more option is while creating user and assigning multiple tenants to him you can choose which tenant you want to be his\her default tenant and than choose the default tenant internally during login.

You can also provide a drop-down inside your application which will have all other tenants he belongs to and can switch his tenants from there.

2. In case you have same data for all the tenants for example your master entities , you dont need to make that table as multi tenant and the data will be shared across all the tenants.It depends upon the business case and data security to not even share the master data .


Please let me know if i am able to answer your questions or not .


Regards,

-PJ-

Thanks a lot Pramod.

I am now clear on point one.

For point two (add data for other client), I will connect with Mishika and get back to you.

Sure Abdul ,

I would be happy to share things with you ..there is a lot of things that can be considered for your multi-tenant application.

Regards,

-PJ-