How to make custom filter based on MustHaveOrganisationId? #6996
How we can get the data which has MustHaveOrganisationId including child OU, added a custom filter for OU filter, but we need to get the data only under OU and sub OU which user has permission.
Instead of using OrganizationId, you can use Code field or Organization unit and do a query like below:
Organization unit codes are generated according to level of OUs. So if an OU has the code 0001, its children will have 0001.0001, 0001.0002 etc... as the code.
Thanks for your response, That is possible if we do a manual query and we need to do for all entities to get filtered, but my aim was to add as data filters for all entities. My scenario is:
- We have Parent OU as Business Entity Office and Sub OU as Divisions, in an office will have multiple divisions
- The user will have only one or more division access based on permission.
- In all grid, data should be filtered and shown only which user has OU permissions
- Should show all data without filtering if we are not setting any OU permissions for the user
For this, we added MustHaveOrganizationUnit for all entities and we have OU id in all tables. Now we need to add data filters for all tables to filter the data based on WHERE IN permitted OU.
Hi, if you want to implement it as data filter, you can refer to the doc for it. See https://aspnetboilerplate.com/Pages/Documents/Data-Filters
However, do note that evaluating current user PERMITTED OU ids might be too expensive to be calculated for every query, you might want to consider caching it.