Filter aggregate to show the specific user a certain data
Service Studio Version
11.11.2 (Build 43109)

I'm new to OutSystems. I have a certain situation I want to create. 

I have a facility screen with facility aggregate connected to the branch which is a static entity. I have created a user already in our environment with no user role. So if this certain user logged in and he/she go to a facility section she can only see certain data related to the branch. 

For example, forestuser logged in and goes to the facility screen. It will only show the table with data under forest branch. 

How I will filter the aggregate to create that scenario? I've been searching for answers but I cant get it. Thank you.

Solution

Hi Ahnieluo,

Since you are relatively new to OutSystems, I have created an oml which I hope helps.

Based on my understanding of your post, I have a simple design with 3 Entities namely - Facilities, Branch (static) and UserBranch

Note: If you plan to execute the oml then you will have to set up your own data in the Facilities and UserBranch screens because the data in these tables will be lost when I upload my oml to the Forum. 

1. Lets say Facility A has 3 branches associated to it - Forest, Rural, Urban


2. I created 3 users and associated them with the branches as shown below: (I assumed a user could be associated to more than 1 branch just for fun but that's up to your design)


3. When I log in as Ana Martins, I should see only the 'Forest' entry and related data if any:


4. When I log in as Ann Olivarria, I should see 3 branches and related data if any:


The filter logic in Facilities > Preparation > GetFacilitiesAndUserBranches aggregate, where GetUserId() always returns the current logged in user Id, is as shown below:


Hope this helps,

AJ

RestrictUserAccessToBranch.oml

This works! Thank you so much!

Hi Anhieluo,

Based on your description, assuming you have the specific user's branch readily available; for example, in a Local Variable in your screen (e.g. UserBranch of type Branch Identifier), you should be able to solve it by simply adding a Filter similar to the following to an aggregate that has the Facility entity as the source:

Facility.BranchId = UserBranch

Or assuming it is a hard coded value for that specific screen, you could use the static entity identifier directly:

Facility.BranchId = Entities.Branch.Forest

Hopefully that helps a little. If the situation is more complex than any of these cases, we will probably be able to help you in a better way if you can share more details of your database design.

That also helped me thank you. But this is the exact scenario I want it to be. 

I am logged in as Bgcbranch and as you can see there is also another branch that is shown in the table. I want to filter that if I logged in, those who have bgc branch will only be shown and if I want to create another facility the input for the branch will automatically be bgc. I don't know what should I write or do. Let me know if you want to see something. Thank you.

Solution

Hi Ahnieluo,

Since you are relatively new to OutSystems, I have created an oml which I hope helps.

Based on my understanding of your post, I have a simple design with 3 Entities namely - Facilities, Branch (static) and UserBranch

Note: If you plan to execute the oml then you will have to set up your own data in the Facilities and UserBranch screens because the data in these tables will be lost when I upload my oml to the Forum. 

1. Lets say Facility A has 3 branches associated to it - Forest, Rural, Urban


2. I created 3 users and associated them with the branches as shown below: (I assumed a user could be associated to more than 1 branch just for fun but that's up to your design)


3. When I log in as Ana Martins, I should see only the 'Forest' entry and related data if any:


4. When I log in as Ann Olivarria, I should see 3 branches and related data if any:


The filter logic in Facilities > Preparation > GetFacilitiesAndUserBranches aggregate, where GetUserId() always returns the current logged in user Id, is as shown below:


Hope this helps,

AJ

RestrictUserAccessToBranch.oml

This works! Thank you so much!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.