When working with multi-tenant apps, add the ability to show all records relating to shared value
Often in a multi-tenant app or apps where your users need to see all their records as well as records they're mutually associated with, you can do that with a data source filter.
Here's our scenario for this example:
Our objective is to ensure that any user that logs in can see all the Jobs pertaining to the company the particular user is associated with.
Let's review our app structure:
We have a Companies table.
Our Jobs table is connected to each company (each job belongs to one company).
Finally, each user belongs to a single company.
Once you've built your data structure, ensure users only see records belonging to the same company they are associated with.
- Open any data component (Table, List, Calendar etc...) in the pages
- Click on the Data Source navigation menu
- Press Add Filter Group
- Select the connection field which is shared between users and the current table. In our case, we're adding a list of jobs and we want any jobs that belong to the same company as the logged-in user to be displayed. So we'll choose Company
- In the next option, choose is connected to logged in user
- Finally, choose the connection field. In our case, its the Company field in the Users table, so we'll choose: Users > Company