To handle this scenario within my apps, I populate the Gallery's item property with an if/then clause.
Example:
If(User().Email = "appowner@domain.com", DataSource, Filter(DataSource, creator = User().Email)
In this example, the if then clause is used to determine if the user's email address matches the owner of the app. If so, it shows the data source unfiltered. Otherwise, it shows the data source filtered by the creator value in each item within the table. The items will only be displayed if the creator field matches the email address. If the data sources creator field is populated by the person's name, you could use User().DisplayName instead, but User().Email is a more unique (and therefore more secure) value.
Taking this even further: If you want to be able to dynamically delegate admin responsibilities within your app instead of just allowing the app's owner to view all, what I do is add a separate data source which is a User Security Table that I have created. The user security table would have properties such as UserPrincipalName (string) and AdminAccessAllowed (boolean). This data source is loaded into the PowerApp via an invisible form object, with the item set to a lookup where UserPrincipalName = User().Email. The form would then have a checkbox with default value set to AdminAccessAllowed, so that this box is checked if the user has admin access. Going back to the previous if/then clause I could then just check to see if this box is checked, which would then determine whether to show all items or just filter based on user.
Hopefully this is helpful.
------------------------------
Manny Baylor
Director of Technology
Project Chesapeake
------------------------------
Original Message:
Sent: Oct 17, 2022 11:11 AM
From: Prem Guru
Subject: User Specific items in PowerApps Gallery
Hi,
I've created a PowerApp form, within this form, I have a Gallery.
I'm looking for a way, there users will only see their records within the Gallery form.
Whereas the Owner of the App, should be able to see all the records submitted by everyone.
For instance: if there are 10 records created by Andrew and Sandy (5 records each), so Andrew should see only 5 records on his system and Sandy should see 5 records on his system. Whereas all 10 records should be visible to the Owner of the App.
Please advise. Thanks! in advance.
------------------------------
Prem Guru
------------------------------