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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,105)