Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Gallery filter not working in Published version

(0) ShareShare
ReportReport
Posted on by 215

Hi,

I am a beginner. I am developing an application for visitor request and approval process. I am using the code below for the Gallery filter. It works fine in the dev but not in the published version.

 

If(User().Email="XXX" Or "XXX" Or "XXX" Or "XXX" Or "XXX" Or "XXX", Filter(VisitorRequestList,PD_Visit_Required="true" And PD_Manager_Approval<>"Approved"), If(User().Email= "XXX" Or "XXX" Or "XXX" Or "XXX" Or "XXX" Or "XXX" Or "XXX" Or "XXX", Filter(VisitorRequestList,'C&A_Visit_Required'="true" And 'C&A_Manager_Approval'<>"Approved"),If(User().Email="XXX" Or "XXX" Or "XXX" Or "XXX" Or "XXX" , Filter(VisitorRequestList,VE_Visit_Required="true" And VE_Manager_Approval<>"Approved"))))

 

The code may not be efficient. The scenario is there are 3 different departments. When a visitor submits a request, the request should be visible for the approvers of the respective department. The reason I have different email check is because, when a request is submitted to a department, any one of the managers should be able to approve the request. There is no approval flow. If there are 4 managers any one of the 4 in that department can approve the request submitted to that department. 

 

I can see the gallery filtering the correct data in the dev but the published version shows there are no records to approve. Your help with this is highly appreciated.

 

Thanks in advance! 

 

Priya

 

  • PowerUser19 Profile Picture
    PowerUser19 215 on at
    Re: Gallery filter not working in Published version

    Hi @WarrenBelz ,

     

    You are awesome! It worked. I had to use || Or instead of And &&. Thank you so very much! 

  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    Re: Gallery filter not working in Published version

    @PowerUser19 ,

    OK - I can uncomplicate this a bit as I spilt it before due to <> not being Delegable

    With(
     {
     wMatch1: User().Email in ["XXX", "XXX", "XXX", "XXX", "XXX", "XXX"],
     wMatch2: User().Email in ["YYY", "YYY", "YYY", "YYY", "YYY"],
     wMatch3: User().Email in ["ZZZ", "ZZZ", "ZZZ", "ZZZ", "ZZZ", "ZZZ", "ZZZ", "ZZZ"]
     },
     Filter(
     VisitorRequestList,
     (wMatch1 && PD_Visit_Required = "true" && PD_Manager_Approval = Blank()) && 
     (wMatch2 && C&A_Visit_Required' = "true && C&A_Manager_Approval' = Blank()) &&
     (wMatch3 && VE_Visit_Required = "true" && VE_Manager_Approval = Blank())
     )
    )

     

    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

  • PowerUser19 Profile Picture
    PowerUser19 215 on at
    Re: Gallery filter not working in Published version

    Hi @WarrenBelz ,

     

    It is either "Approved" or Blank. No other statuses. My condition for the filter is Not equal to Approved and If visit required for that department is True. Please find the screenshot of the database.

  • WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    Re: Gallery filter not working in Published version

    Hi @PowerUser19 ,

    Thats what I thought - I just wanted to check the values were returning something. What other status value exist other than Approved?

  • PowerUser19 Profile Picture
    PowerUser19 215 on at
    Re: Gallery filter not working in Published version

    Hi @WarrenBelz ,

    Now I am able to see all records. Approved records are showing in the Gallery as well. 

  • WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    Re: Gallery filter not working in Published version

    @PowerUser19 ,

    Try Or || instead of And && on the bottom two sections

  • PowerUser19 Profile Picture
    PowerUser19 215 on at
    Re: Gallery filter not working in Published version

    Hi @WarrenBelz ,

    My sincere apologies for late response. Was unwell last couple days and didn't get a chance to try this. I tried the code now which removed the warning but not showing any record in the gallery. May be some minor fix is required. With my old code, I see the records with warning though. Your help is much appreciated.  Attaching the screenshots.

  • WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    Re: Gallery filter not working in Published version

    Hi @PowerUser19 ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    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

  • WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    Re: Gallery filter not working in Published version

    @PowerUser19 ,

    A bit clunky, but this should do it. Note however that the output of the second With() statement is limited to records numbers of your Delegation limit

    With(
     {
     wMatch1: User().Email in ["XXX", "XXX", "XXX", "XXX", "XXX", "XXX"],
    	 wMatch2: User().Email in ["YYY", "YYY", "YYY", "YYY", "YYY"],
    	 wMatch3: User().Email in ["ZZZ", "ZZZ", "ZZZ", "ZZZ", "ZZZ", "ZZZ", "ZZZ", "ZZZ"]
     },
     With(
     {
     wList:
     Filter(
     VisitorRequestList,
     (wMatch1 && PD_Visit_Required = "true") && 
     (wMatch2 && C&A_Visit_Required' = "true) &&
     (wMatch3 && VE_Visit_Required = "true")
     )
     },
     Filter(
     wList:
     (wMatch1 && PD_Manager_Approval <> "Approved") && 
     (wMatch2 && 'C&A_Manager_Approval' <> "Approved") &&
     (wMatch3 && VE_Manager_Approval <> "Approved")
     )
     )
    )

     

    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

  • PowerUser19 Profile Picture
    PowerUser19 215 on at
    Re: Gallery filter not working in Published version

    Hi @WarrenBelz ,

     

    Thank you so much. I will try this code. Yes, I did get a delegation warning with my original code as well. Is there any way to resolve it? Or is there any other better way to do this filter (using the same conditions) to avoid the delegation warning?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard