Multi Tenant questions

Multi Tenant questions

Hello everybody. I have a question with multi tenant. I set my application to support multi tenant, so far no secrets. I have clients who hire me my system several times, one per company(to me one company = one tenant inside the plataform), and at times for example in locating a client he wants to find it in all his tenants. This leads me to some questions actually:
1 - Is it possible to one user inside the plataform see many tenants? Can I associate a user with many tentants?
2 - I can do research on various tenants and show in a unique list?
3 - How to share data between tenants, when the owner of several companies is actually just one person?

Alexandre -

1. Yes, if that user is working within a *single tenant* eSpace, or you expose the tenant IDs on the data. You cannot (to the best of my knowledge, someone else may know a way to do it) have a user associated with multiple tenants.

2. Yes, add a reference to the "Tenant" entity in System to work with the list of tenants.

3. Make the entity you need to share set to "Multi Tenant" = "No", or put it in a single tenant eSpace, or expose the tenant ID so a user can look through all of the data.

Hi Justin thank you for your answers but I don't understand somethings. In answer one you tell me that one user can see many Tenants, once the user are logged I can set to another tenant without problem? How can I do this? In my question 3 when I ask if can I share data between Tenant it's not disable tenant of a table, the data need to be separeted but in some reports or screens I need to list all clients of multiple tenants.. do you understand?

Hi Alexandre,

Have you read the Service Studio Help topics about Multi-tenantcy?

Also, checkout the How to build a Multi-tenant Application tech note. The tech note is packed with a sample application that implements a multi-tenant application, allows users to provision their own tenants, and also has a back office that allows to manage all tenants (I think this helps addressing your question #2).

Let me just briefly explain how the multi-tenancy works:

When creating entities in Service Studio, you change the 'Is Multi-tenant' property to 'Yes'. This means that from now on, every query or data manipulation is constrained to its tenant:
  • If users of the FishParadise tenant (example used in the Service Studio Help) create a new 'Golden Fish';
  • If users of the TropicalJoy tenant create the 'Cod Fish' and 'Shark'
When running a query on the 'Fish' entity, the result depends on the user that executes the query: if it's a user from the FishParadise he will only see 'Golden Fish', if the user is from the TropicalJoy, he will only see 'Cod Fish' and 'Shark'.

As said, this is the default behavior of the platform, and is probably what you'll need 80% of the the times.

For the other 20%, as Justin explained:
  • You can leave your entity with 'Is Multi-tenant' set to 'No' - independently of the tenant that the user belongs the query will return the 3 fishes (golden, cod and shark)
  • You can set the 'Show Tenant Identifier' property to 'Yes'. the behavior the the same as above (the platform does not automatically segment the data), but a new column will appear in your entities. And it is up to you to make the queries filter the data based on the tenant identifier or any other criteria.

Hi i have another question about multi tenant. If I have a timer that delete temporaly records from my tables, but this tables are tenant = true, if I sad to plataform that this timer isn't multi tenant the advanced query inside my timer will delete temporary records from all my tenants? 

To explain more: I have a timer that run an action CleanAllTempraryEntities, inside this action I have many Advanced queries that execute a code like bellow:

DELETE FROM {Cliente} WHERE {Cliente}.[Codigo] is null or {Cliente}.[Codigo] = 0

But my table Cliente is multi tenant, I need that this timer is multi tenant too? Or if this timer isn't multi tenant it willdelete all records my Cliente table of all tenants?

Thanks again.
Thanks Joao I will now read all documentation that you showed me. But behavior when 'Show Tenant Identifier' = yes is very interesting. I can do this by code? My client will have a check box on the screen and when clicked I will pass this property to true and change my filter of query with tenants of my cliente, is it possible?
This answer my question about timer:

 Timers: Allow narrowing the scope of execution of timers by tenant. Single-Tenant timers will run on the default tenant (which has the same name of the User Provider application).

So I need a timer per tenant in my case.
Regarding the timer, you need a Timer with multi-tenant set to 'Yes'. The timer will run once for each tenant.

The property is only specified at design time, so it is not possible to change it when the application is running. My advice would be for you to read the documentation I showed above, and then install and explore the example application in the 'How to build a multi tenant application' tech note
Hi João, I'm reading now. My scenario is really complex. My application is multi-tenant but some of my clients have more than one tenant in the system and at times need to research these tenants and integrated reporting. In research for example when he search for a particular client, I'll have to put together a list of my client tenants,  in the first tenant save to a list in memory use SwitchTenant do a search again and add memory and so on, after having searched all the tenants I will show a table point to this memory variable. There is only this way? Ideally I talk to plataform which tenants I want to do a search.
Alexandre -

The answer to your needs is really to make a separate layer for the data/data access logic. Do NOT use TenantSwitch if at all possible, because it completely clears your session! Instead, using the seperate data layer, create Web Services that perform the functionality. Those services should just wrap your actions, and accept a tenant ID as well. They can perform the TenantSwitch, and because it is a disconnected process, it won't ruin your user's session.

Thanks Justin, thanks Joao, with some help of you and my friend Rui David I solve problem, in my case I use TenantSwitch and work with session problems. Thanks for help.
Hi Guys,

The tenant functionality is a very interesting topic.
The needed tenant implementation for the situations I know isn't 'straightforward' enough to actually make use of the Multi Tenant switch.

In my opinion two major features are 'lacking'
1. Usually you would want at least a 'Maintainer' that can cover all of the Tenants or report on them or maintain 'shared' tables.
    Needing this you'd need to switch to either an advanced query in which you leave out the Tenant Id; creating a double 'complexity' layer (Both the moving to an advanced query and the usage of the TenantId) or you need your own setup
2. Whenever you'd 'sell' your product SAAS based; you'll hope to have customers returning.
    In those cases the customers don't want to have a fresh login for every company / daughter company they own.
    The user - tenant relation shouldn't be 1:1 but 1:N enabling features like reporting 'over' companies.

Would be nice if the Platform would be extended with at least these features.
Also an hierarchy can be more complex than that.
We've created our own setup comparible to the TenantId principle that actually 'adds' an extra
statement to every Advanced query in order to show the proper data.

Note that in a lot of situations this functionality can be 'cached' which makes responsiveness quite good.
Hi All,

I am using OutSystems Platform since its version 7. We have multiple tenants in our app. The user provider espace has been specified as Multi-tenant (i.e. Is Multi-tenant = Yes)

To enable Admin users, who should see some things across tenants, we have another espace which is set as Not Multi-tenant (i.e. Is Multi-tenant = No). For certain entities, which we want to query tenant indepdent, we have checked corresponding 'Show Tenant Identifier' check boxes. We call this espace TenantIndependent. It works fine in personal space and main area.

Earlier, I was able to query my database, across tenants, in this espace. I do not know exactly when, but I suspect that it was when we upgraded to version 8, I am unable to run my queries across tenants in this espace. Currently, we are using version 9 of the platform.

e.g. I simply want to get the list of all records of a table lets say A, for which I have checked 'Show Tenant Identifier' in 'Advanced' tab of the entity and the entity icon is red. I am not getting the list. When I select a tenant, from the drop down given with 'Test' button in query, I get records specific to only that tenant.

Has this feature been taken back or there is some bug? I am not sure if there is a configuration in Service Studio or Service Center which has changed this behavior.

Please note that I have been using OutSystems Platform for over two years now and I think I understand what multi-tenancy is and I have successfully been using it to develop my application. And my application is live since last 8 months with thousands of page requests every day.