Hello,

I need to do one query using SQL Advanced with TenantId. I am trying to do e I am receveing one mistake talking mult-part TenantId could not found. Somebody know how to do one query usingTenantId?


Thanks

André Luiz



Hello Andre,


Check this link, hope it helps.

https://www.outsystems.com/forums/discussion/21860/multi-tenant-advance-query/


Jorge Rodrigues


Hi,

First you need to make sure you show tenant id column by going to entity --> more --> advanced and entity is marked as multi tenant or module is marked as multi tenant, in my contact entity below Is Multi-tenant option is taken from module and my module is marked as multi tenant.

Once you have the tenant id shown then you can query it as usual in advance query, for example like below

SELECT {Contact}.* 
from {Contact}
where {Contact}.[Tenant_Id] = @TenantId 
order by @OrderBy;

Best if you go through the course https://www.outsystems.com/learn/courses/45/master-class-on-multi-tenancy/. I learned most of the concept from that course.

Regards.

HI Andre ,

Could you please add some more details about your issue ? There is no difference in writing advance query or writing advance query for multi tenant entities.

@Prasad Rao - Checking "Show Tenant Identifier"  is not required to write multi tenant advance query because the  platform manage this automatically based on the logged in user tenant id. if you check "Show Tenant Identifier" than platform will not add the tenant filter automatically and the query will work for all the tenants.


Regards,

-PJ-

Hi,

Correct if you don't check "Show Tenant Identifier" then we will not be able add custom filter on tenant id, platform will filter on tenant based on logged in user.

I assumed Andre wanted to add custom filter on the tenant id and hence I suggested to check "Show Tenant Identifier" on entity.

Regards.

Hi André,

Please clarify it in more detail. so we can able to provide a required solution.

Thank you,

Sudip

Hi,

first all, check this documentation: How to Build a Multi-tenant Application

Cheers,

Nuno Verdasca

Hi,

Please check the Application in the forge to get an idea of how to build a multi Tenant Application.

https://www.outsystems.com/forge/component-overview/5756/multi-tenant

I hope it will help you to get an Idea of Multi-Tenant.

Thank you,

Sudip