Power Apps Exchange

Please login or click SIGN UP FOR FREE to create your PowerAppsUG account to join this user group.
 View Only
  • 1.  User Specific items in PowerApps Gallery

    Bronze Contributor
    Posted Oct 17, 2022 11:11 AM
    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
    ------------------------------


  • 2.  RE: User Specific items in PowerApps Gallery

    Posted Oct 18, 2022 02:02 AM
    Edited by Michael Nunes Oct 18, 2022 02:04 AM
    Hi
    Please check out these posts

    3 Ways To Filter A Power Apps Gallery By The Current User (matthewdevaney.com) or
    Solved: User should see their own records alone - Power ap... - Power Platform Community (microsoft.com)

    Use either the ability to filter the records by user who created or to apply permissions on the data. The later is based on the data source of course.


    ------------------------------
    Mickey Nunes

    ------------------------------



  • 3.  RE: User Specific items in PowerApps Gallery

    Posted Oct 18, 2022 09:54 AM
    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
    ------------------------------



  • 4.  RE: User Specific items in PowerApps Gallery

    Bronze Contributor
    Posted Oct 19, 2022 10:49 AM
    @Michael Nunes - Thank you for sharing the link. I'd been through the site and see applying the settings into SharePoint will fulfill my requirement to some extend. Will look around other link and do some testing. Thank you once again.

    @Manny Baylor - Thank you so much for such a brief description. I'm just wondering if applying just the below formula, will solve my issue?

    Example:
    If(User().Email = "appowner@domain.com", DataSource, Filter(DataSource, creator = User().Email)​​​

    ------------------------------
    Prem Guru
    ------------------------------



  • 5.  RE: User Specific items in PowerApps Gallery

    Posted Oct 19, 2022 11:19 AM
    Yes, I would expect that simply using this formula would work for your scenario.

    ------------------------------
    Manny Baylor
    Director of Technology
    Project Chesapeake
    ------------------------------



  • 6.  RE: User Specific items in PowerApps Gallery

    Posted Oct 26, 2022 06:24 AM
    HY, Here's the Solution;  Go to the items property of the Gallery and write this:  Filter(yourdatasourcename,'Created by'.email = User().Email).

    ------------------------------
    Muhammad Garba
    Software Developer
    ------------------------------