cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerappsrooki
Regular Visitor

Filter Gallery based on user logged in and also show all the records to admin user

Hello,

I am new to the power apps, I am able to filter the gallery based on user logged in as per below:

App.OnStart – Set(varUser, User());

App.Items -  Filter(‘TestSharePointList’, Email = varUser.Email);

 

However, how can we show all the records of the gallery to Admin along with above? 

 

Please help! 

Thanks
Anmol

1 ACCEPTED SOLUTION

Accepted Solutions
Feiteira
Resolver II
Resolver II

Hi there @powerappsrooki

 

First of all welcome to the #PowerAddicts family 😊

 

If you want to show Records to "Normal users" and "Admins", you will have to set those users somewhere.

Here are some options:

  • O365 Groups
  • SharePoint List
  • Additionaly, you could use security roles if you were using Dataverse.

 

As a quick fix I suggest you use a SharePoint List to configure who are the Admins. Nevertheless, if you need a more robust and secure fix, use O365 Groups (the better practice)

 

Using a SharePoint List you just need to add a collumn of type "Person or Group " (lets call it "User") in that list (lets now called it "PowerAppAdmins") and insert the users you want to.

 

On the PowerApp side, you can then use this:

On the OnStart

If(
    IsBlank(LookUp('PowerAppAdmins', ThisRecord.User.Email = varUser)),
    Set(
        Admin,
        false
    ),
    Set(
        Admin,
        false
    )
)

On the Items

If(
    Admin,
    TestSharePointList,
    Filter(‘TestSharePointList’, Email = varUser.Email);
)

 

This way you have two account types, the Admin one, who needs to be listed in the SharePoint List called "PowerAppAdmins" and the default user type, who can only see his records.

 

 

Let me know if this worked out for you 😀

View solution in original post

6 REPLIES 6
poweractivate
Super User
Super User

App doesn't have an Items property, Do you mean Gallery control Items property?

 

//pseudo formula, modify as needed
If
(
   ,LookUp(SomeUserStatusList, Email = varUser.Email).SomeStatusColumn = "Admin"
   ,'TestSharePointList'
   ,Filter('TestSharePointList', Email = varUser.Email)
)

 

Does it help @powerappsrooki ? You may need to modify above as appropriate.

Feiteira
Resolver II
Resolver II

Hi there @powerappsrooki

 

First of all welcome to the #PowerAddicts family 😊

 

If you want to show Records to "Normal users" and "Admins", you will have to set those users somewhere.

Here are some options:

  • O365 Groups
  • SharePoint List
  • Additionaly, you could use security roles if you were using Dataverse.

 

As a quick fix I suggest you use a SharePoint List to configure who are the Admins. Nevertheless, if you need a more robust and secure fix, use O365 Groups (the better practice)

 

Using a SharePoint List you just need to add a collumn of type "Person or Group " (lets call it "User") in that list (lets now called it "PowerAppAdmins") and insert the users you want to.

 

On the PowerApp side, you can then use this:

On the OnStart

If(
    IsBlank(LookUp('PowerAppAdmins', ThisRecord.User.Email = varUser)),
    Set(
        Admin,
        false
    ),
    Set(
        Admin,
        false
    )
)

On the Items

If(
    Admin,
    TestSharePointList,
    Filter(‘TestSharePointList’, Email = varUser.Email);
)

 

This way you have two account types, the Admin one, who needs to be listed in the SharePoint List called "PowerAppAdmins" and the default user type, who can only see his records.

 

 

Let me know if this worked out for you 😀

@Feiteira Thanks for the detailed response! 🙂

@Feiteira After I checked your response, I also modified my formula to be more correct,  I noticed it was not initially until now.

However, the modifications @powerappsrooki has to make to my pseudo-formula I gave, might need to be the ones you described in more detail, so thank you for providing the additional details @Feiteira .

Feiteira
Resolver II
Resolver II

Thank you @poweractivate , much apreciated coming from you 😀

Now lets see if our buddy @powerappsrooki can get it to work like that 😋

Thank you so much, Yes, this is how I wanted. @Feiteira

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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