cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alois
Helper III
Helper III

Filter Gallery Items based on two lookup sharepoint list columns

Hi All,

I am developing a logistics apps with the following variables set OnStart. These variables are used to determine if the user has certain visibility for case management (i.e. Approve/Reject).

//Set user based security
Set(varUser,User());
Set(isUserAdminSPList,!IsBlank(LookUp('User Roles',User.Email=varUser.Email&&Role.Value="Administrator")));
Set(isUserCMSPList,!IsBlank(LookUp('User Roles',User.Email=varUser.Email&&Role.Value="Construction Manager")));
Set(isUserPMSPList,!IsBlank(LookUp('User Roles',User.Email=varUser.Email&&Role.Value="Project Manager")));
Set(isUserBUHSPList,!IsBlank(LookUp('User Roles',User.Email=varUser.Email&&Role.Value="BUH")))

*'User Roles' is the name of my sharepoint list.

Attached a screenshot of a filtered gallery showing only items made by current user through condition:

varUser.Email = User.Email

Alois_0-1637905758372.png


How do I allow for other users such as:
1. isUserAdminSPList to be able to view all items in the gallery 
2. isUserCMSPList to be able to view all items in the gallery for the identified 5 sites they belong to

Attached the screenshot of 'User Roles'

Alois_1-1637906299297.png


I think the logic to go about is:

If(isUserAdminSPList, <view all gallery items>, <filter only current user items>)

If(isUserCMSPList, <view all gallery items for the 5 project sites>, <filter only current user items>)




1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Alois ,

Firstly, do this OnStart

Set(varUser,User());
Set(
   varUserDetails,
   LookUp(
      'User Role',
      User.Email=varUser.Email
   )
);
Set(
   isUserAdminSPList,
   varUserDetails.Role.Value = "Administrator"
);
Set(
   isUserCMSPList,
   varUserDetails.Role.Value = "Construction Manager"
);
Set(
   isUserPMSPList,
   varUserDetails.Role.Value = "Project Manager"
);
Set(
   isUserBUHSPList,
   varUserDetails.Role.Value ="BUH"
)

then your gallery Items

Sort(
   Filter(
      'PTC Logistics Records', 
      Status.Value = "Pending" &&
      (
         isUserAdminSPList ||
         (
            'Project Site'.Value = varUserDetails.Sitel.Value || 
            'Project Site'.Value = varUserDetails.Site_x0020_2.Value || 
            'Project Site'.Value = varUserDetails.Site_x0020_3.Value || 
            'Project Site'.Value = varUserDetails.Site_x0020_4.Value || 
            'Project Site'.Value = varUserDetails.Site_x0020_5.Value
         )
      ) 
   ),
   YourSortField,
   Descending
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

1 REPLY 1
WarrenBelz
Super User
Super User

Hi @Alois ,

Firstly, do this OnStart

Set(varUser,User());
Set(
   varUserDetails,
   LookUp(
      'User Role',
      User.Email=varUser.Email
   )
);
Set(
   isUserAdminSPList,
   varUserDetails.Role.Value = "Administrator"
);
Set(
   isUserCMSPList,
   varUserDetails.Role.Value = "Construction Manager"
);
Set(
   isUserPMSPList,
   varUserDetails.Role.Value = "Project Manager"
);
Set(
   isUserBUHSPList,
   varUserDetails.Role.Value ="BUH"
)

then your gallery Items

Sort(
   Filter(
      'PTC Logistics Records', 
      Status.Value = "Pending" &&
      (
         isUserAdminSPList ||
         (
            'Project Site'.Value = varUserDetails.Sitel.Value || 
            'Project Site'.Value = varUserDetails.Site_x0020_2.Value || 
            'Project Site'.Value = varUserDetails.Site_x0020_3.Value || 
            'Project Site'.Value = varUserDetails.Site_x0020_4.Value || 
            'Project Site'.Value = varUserDetails.Site_x0020_5.Value
         )
      ) 
   ),
   YourSortField,
   Descending
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,666)