cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lefty
Impactful Individual
Impactful Individual

Gallery filtering issues

Hi,

 

I have a gallery where I am trying to display only items where users are reviewers or if the user is the person who raised the item. It appears all the items are visible to all users, and I cannot figure out from my code why, on my items property of my gallery I have:

 

 

Sort(
    Filter(
        List,
        (
        'Created By'.Email = vUser ||
        LineManager.Email = vUser ||
        Approver1.Value = vUser ||
        Approver12.Email = vUser ||    
        Approver13.Email = vUser ||
        "Email1" = vUser ||
        "Email2" = vUser ||
        "Email3" = vUser ||
        Lower("Email4") = Lower(vUser) ||
        vUser = "Email5" ||
        CurrentUser.Email in MyMngr.MyUser 
    ) 
    
    &&


    StartsWith(
        YourName.DisplayName,tbSearchInput.Text)
        Or StartsWith(RefNumber,Trim(tbSearchInput.Text)) 
   ),
   

  ID,
  Descending
)

 

I would expect the above code to display items to only those users who are named in any of the above values or any user in the MyMngr table which I have set at App startup, but all items are visible to all users. regardless of the above.... any ideas?

 

Thanks

 

13 REPLIES 13

I think if we split this into two separate conditions then we can decisively say whether all users are seeing all items:

If(
   //if in MyMngr then only filter by the searchbox
   CurrentUser.Email in MyMngr.MyUser,
   Sort(
        Filter(
            List,
            (
                Len(tbSearchInput.Text)=0 //not filtering if the length of the text in the search textbox is zero 
                ||
                (
                    StartsWith(YourName.DisplayName,tbSearchInput.Text)
                    ||
                    StartsWith(RefNumber,Trim(tbSearchInput.Text))
                ) 
            )
        ),
    ID,
    Descending
    )

    ,
    
    //if not in Mymngr, then do normal filter plus searchbox
    Sort(
        Filter(
            List,
            (
            'Created By'.Email = vUser ||
            LineManager.Email = vUser ||
            Approver1.Value = vUser ||
            Approver12.Email = vUser ||    
            Approver13.Email = vUser ||
            "Email1" = vUser ||
            "Email2" = vUser ||
            "Email3" = vUser ||
            Lower("Email4") = Lower(vUser) ||
            vUser = "Email5"
            ) 
            &&
            (
                Len(tbSearchInput.Text)=0 //not filtering if the length of the text in the search textbox is zero 
                ||
                (
                    StartsWith(YourName.DisplayName,tbSearchInput.Text)
                    ||
                    StartsWith(RefNumber,Trim(tbSearchInput.Text))
                ) 
            )
        ),
    ID,
    Descending
    )
)

 

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Lefty
Impactful Individual
Impactful Individual

Hello @iAm_ManCat 

 

Thanks for coming back to me, with what appears to be a working fix to my issue.

 

As the app was in prod, I needed a quick fix and after messing around for a long time, I decided to scrap the table of users on my App OnStart and just explicitly mention the email adds of the users in the first filter query, which appears to be working (until I realise something else is broken)!

 

I'm reluctant to give your suggested option a try as if I break it again I could get some very unhappy users. If I find there is another issue, I will give your suggested way a try. I really appreciate you coming back to me on this one.

Just a tip - use Save As to create a copy of the App for testing purposes and share that Test app with just one user who you expect to NOT see all the data, that way you can test on a separate app without having all of the other prod users affected 🙂

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Lefty
Impactful Individual
Impactful Individual

Thanks @iAm_ManCat 
I have been in discussions with product owner to provide a separate environment, but this could potentially be far easier!

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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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
Users online (1,470)