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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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