8d592bb54fc7d4888136c2250998dcb15cf959c2
FAQ/Questions/reports-and-tenants.md
| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | +#Reports and Tenants |
|
| 2 | + |
|
| 3 | +[[_TOC_]] |
|
| 4 | + |
|
| 5 | +##Question |
|
| 6 | + |
|
| 7 | +How does Izenda support multi-tenant and cloud computing systems? |
|
| 8 | + |
|
| 9 | +##Answer |
|
| 10 | + |
|
| 11 | +Izenda supports these systems with several properties designed specifically for multi-tenant systems. Here is a basic overview of these properties and their functionality. |
|
| 12 | + |
|
| 13 | +###Tenant system overview |
|
| 14 | + |
|
| 15 | +Here are the basic principles behind how tenants integrate with reports: |
|
| 16 | + |
|
| 17 | +* Every ReportSet has an **OwnerTenantID**. |
|
| 18 | +* Every user session is associated with one [[CurrentUserTenantId|/API/CodeSamples/CurrentUserTenantId]] that is empty by default. |
|
| 19 | +* When a ReportSet is being saved, its **OwnerTenantID** gets the value of whatever is in [[CurrentUserTenantId|/API/CodeSamples/CurrentUserTenantId]]. |
|
| 20 | + |
|
| 21 | +This means that a ReportSet will not be accessible to the user if their [[CurrentUserTenantId|/API/CodeSamples/CurrentUserTenantId]] doesn’t match the ReportSet's OwnerTenantID. |
|
| 22 | + |
|
| 23 | +Here is a chart demonstrating accessibility between a user's CurrentUserTenantId and the ReportSet's OwnerTenantId: |
|
| 24 | + |
|
| 25 | +| |**CurrentUserTenantId**|none|"Tenant_1"|"Tenant_2"| |
|
| 26 | +|:---------------:|:---------------------:|:--:|:--------:|:--------:| |
|
| 27 | +|**OwnerTenantID**| | | | | |
|
| 28 | +|none | | + | + | + | |
|
| 29 | +|"Tenant_1" | | - | + | - | |
|
| 30 | +|"Tenant_2" | | - | - | + | |
|
| 31 | + |
|
| 32 | +**Legend:** (+) Accessible (-) Not Accessible |
|
| 33 | + |
|
| 34 | +###Tenant Field |
|
| 35 | + |
|
| 36 | +The [[TenantField|/API/CodeSamples/TenantField]] setting allows per-report filtering based on the value of the user's [[CurrentUserTenantId|/API/CodeSamples/CurrentTenantId]]. Here are the rules about **ReportSets**. |
|
| 37 | + |
|
| 38 | +* Every **ReportSet** contains a list of the **DataSources** used with it. |
|
| 39 | +* Every **DataSource** has a list of **Fields** associated with it. |
|
| 40 | +* Every **Field** can have a set of applied **Filters**. |
|
| 41 | + |
|
| 42 | +This creates a high level of control over what is filtered. Essentially, the system will look at the ReportSet's DataSources, find the Field specified by [[TenantField|/API/CodeSamples/TenantField]] and apply a hidden filter to that field using the value of the user's [[CurrentUserTenantId|/API/CodeSamples/CurrentTenantId]]. |
|
| 43 | + |
|
| 44 | +So, if the [[TenantField|/API/CodeSamples/TenantField]] property is specified, the hidden filter of the user's [[CurrentUserTenantId|/API/CodeSamples/CurrentTenantId]] will be added every time report is populated. |
|
| 45 | + |
|
| 46 | +So, the generated SQL will look like the following: |
|
| 47 | + |
|
| 48 | +```sql |
|
| 49 | +SELECT [TenantField] FROM [DataSource] |
|
| 50 | +WHERE ... AND [TenantField] = 'CurrentUserTenantId' |
|
| 51 | +``` |
|
| 52 | + |
|
| 53 | +**For example:** |
|
| 54 | +Let’s create a report with information about customers' orders: |
|
| 55 | + |
|
| 56 | +![Customer order report]() |
|
| 57 | + |
|
| 58 | +If [[TenantField|/API/CodeSamples/TenantField]] is NOT specified we will see the following report: |
|
| 59 | + |
|
| 60 | +![Customer order report output]() |
|
| 61 | + |
|
| 62 | +Now let’s specify [[TenantField|/API/CodeSamples/TenantField]] and [[CurrentUserTenantId|/API/CodeSamples/CurrentTenantId]]: |
|
| 63 | + |
|
| 64 | +```csharp |
|
| 65 | +public class CustomAdHocConfig : DatabaseAdHocConfig |
|
| 66 | +{ |
|
| 67 | + public static void InitializeReporting() |
|
| 68 | + { |
|
| 69 | + AdHocSettings.TenantField = "CustomerID"; |
|
| 70 | + AdHocSettings.CurrentUserTenantId = "ALFKI"; |
|
| 71 | + } |
|
| 72 | +} |
|
| 73 | +``` |
|
| 74 | + |
|
| 75 | +With these properties set, we will see a completely different report: |
|
| 76 | + |
|
| 77 | +![customer order report filtered]() |
|
| 78 | + |
|
| 79 | +As you can see the results are filtered by the “Customer ID” field now. And only those matching “ALFKI” will be populated. |
|
| 80 | + |
|
| 81 | +_**Note:** You must always specify [[CurrentUserTenantId|/API/CodeSamples/CurrentTenantId]] to use [[TenantField|/API/CodeSamples/TenantField]]. The only exception is reports scheduler (details in the below section)._ |
|
| ... | ... | \ No newline at end of file |