Hi everyone,

I am currently developing the Contacts App of the Multitenant Masterclass in order to implement the MT login as depicted in the end of the presentation. So far I develped the whole process with changes in the login screen and flows. Also created the same User in 3 different Tenants, but it seems at login that the TenantSwitch Action does not produce the expected result that would be the user session to be in the chosen Tenant. Also to verify this I gave the same Username but different Names to the User so for each different Login he would have a different Name . The User keeps loging in the first Tenant no matter whats chosen. 

So when in enters afterwards in the Contacts App all the contacts are stored in the "ManagerContacts" Tenant - always.

I tried with other Users that dont have more than one Tenant and all works as expected - they to to their (only) Tenant.

Below the picture of screen and flows so far.

Where is the problem?

Thank you in advance

---

Platform Version 11.7.3 (Build 5968)

SStudio 11.7.4

-----

Tenants and User

----

Flow of the Login Action

----

Flow of Login in Tenant Flow

------

Debugger shows correct TenantId as chosen in ComboBox

Login screen


Rui Barata wrote:

Hi everyone,

I am currently developing the Contacts App of the Multitenant Masterclass in order to implement the MT login as depicted in the end of the presentation. So far I develped the whole process with changes in the login screen and flows. Also created the same User in 3 different Tenants, but it seems at login that the TenantSwitch Action does not produce the expected result that would be the user session to be in the chosen Tenant. Also to verify this I gave the same Username but different Names to the User so for each different Login he would have a different Name . The User keeps loging in the first Tenant no matter whats chosen. 

So when in enters afterwards in the Contacts App all the contacts are stored in the "ManagerContacts" Tenant - always.

I tried with other Users that dont have more than one Tenant and all works as expected - they to to their (only) Tenant.

Below the picture of screen and flows so far.

Where is the problem?

Thank you in advance

---

Platform Version 11.7.3 (Build 5968)

SStudio 11.7.4

-----

Tenants and User

----

Flow of the Login Action

----

Flow of Login in Tenant Flow

------

Debugger shows correct TenantId as chosen in ComboBox

Login screen


Hi Rui, can you upload the oml so we can check the logic there?


Hi Rui,

As per Outsystems Documentation, End user belongs to a particular tenant. Did you try creating users with different user names across tenant or internally change the username to username+tenantid and check against users table ?

Since an end-user uniquely belongs to a tenant, in the login process, the OutSystems Platform infers the tenant an end-user belongs using the username. Then, the end-user is bound to his tenant and all Simple and Advanced Queries are automatically filtered to only return data from that tenant.

Documentation Link 

Thanks

Ravi

Carlos Lessa wrote:

Rui Barata wrote:

Hi everyone,

I am currently developing the Contacts App of the Multitenant Masterclass in order to implement the MT login as depicted in the end of the presentation. So far I develped the whole process with changes in the login screen and flows. Also created the same User in 3 different Tenants, but it seems at login that the TenantSwitch Action does not produce the expected result that would be the user session to be in the chosen Tenant. Also to verify this I gave the same Username but different Names to the User so for each different Login he would have a different Name . The User keeps loging in the first Tenant no matter whats chosen. 

So when in enters afterwards in the Contacts App all the contacts are stored in the "ManagerContacts" Tenant - always.

I tried with other Users that dont have more than one Tenant and all works as expected - they to to their (only) Tenant.

Below the picture of screen and flows so far.

Where is the problem?

Thank you in advance

---

Platform Version 11.7.3 (Build 5968)

SStudio 11.7.4

-----

Tenants and User

----

Flow of the Login Action

----

Flow of Login in Tenant Flow

------

Debugger shows correct TenantId as chosen in ComboBox

Login screen


Hi Rui, can you upload the oml so we can check the logic there?


Hi Carlos,

thank you for the quick reply. In attach you find the oml.

Thanks again


Ravi Vakkalanka wrote:

Hi Rui,

As per Outsystems Documentation, End user belongs to a particular tenant. Did you try creating users with different user names across tenant or internally change the username to username+tenantid and check against users table ?

Since an end-user uniquely belongs to a tenant, in the login process, the OutSystems Platform infers the tenant an end-user belongs using the username. Then, the end-user is bound to his tenant and all Simple and Advanced Queries are automatically filtered to only return data from that tenant.

Documentation Link 

Thanks

Ravi

Hi Ravi, thank you for your reply. The use case that I want to check is that if the username is only bound to one tenant ( I mean, one username per tenant) he will start is session at the correct tenant - and that works. But it is possible to have the same username (as if it was the same person) into several tenants and in that case it's given the choice to the user on which he wants to start his session. Below UserMT records view.


 


Solution

Rui,


To achieve what you want you can do the following:

Since you already have a customize login where the user can enter the username, password and tenant, the next step is for you to control the login action.

For that you can use system actions like LOGIN or LOGIN_PASSWORD


You also need to expose the tenantId at users entity (by double clicking the entity)


After that, on your login action you need to perform a query to fetch the correct user with the information that you retrieved from the login page (username/password/tenant).

Once you get the correct userId you can switch to the tenant selected by the user and perform your customize login to the correct tenant:


I hope this helps you.


Kind regards,

Hugo


Solution

Thank you Hugo,

that gave the right push to my final and working solution.

All the best

I'm glad I could help.


All the best Rui