cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AppDeveloper
Helper III
Helper III

Display data to Creator and Admin

Hi All,

From a SharePoint List i want to Show items in Gallery to only the user who created those. But i want Admin to see all of them.

my 

Items = Filter('HUG List','Creator Email' = UserDetails.Email)

Where

Hug List = data source,

Creator Email =  is email of the user who created it,

UserDetails is a variable at the start of App.

 

How can i add a specific email which belongs to Admin so he can see all items while restricting others to see only those which belong to them? My admin email is  say xyz@mycompany.com.

 

Many Thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions
eka24
Super User
Super User

If (User(). Email="xyz@Mcompany.com",
'HUG List',
Filter('HUG List','Creator Email' = User().Email))

 

If you have the admin mail in the created column use:

If ('Created Email'="xyz@Mycompany.com",
'HUG List',
Filter('HUG List','Creator Email' = User().Email))

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

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

v-yutliu-msft
Community Support
Community Support

Hi @AppDeveloper ,

Do you want to display all data when current user is the admin , display filtered data when current user is not the admin?
Could you tell me how many admins in your issue?

You could decide the app's mode whether for admin when starting the app.

1)If there's only one admin, you should set the app's OnStart:

If(User().Email="xyz@mycompany.com",Set(adminmode,true)
)

2)If there are more than one admins , you should set the app's OnStart:

If(User().Email in ["xyz@mycompany.com","emailaddress2","emailaddress3",....],
Set(adminmode,true)
)

 

Then set the gallery's Items:

If(adminmode,
 'HUG List',
 Filter('HUG List','Creator Email' = UserDetails.Email)
)

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8

You need some way to determine who is an administrator. something like an app administrator list. then use In operator to see if User() is in the administrator list.

 

there is a setting in the list to allow users to only see records that they created, but that will also limit your admin.

 

If this is really sensitive data it should not be in sharepoint lists. there is no real granular security in sharepoint lists--you can obscure it in the app, but the user also has access to the SharePoint list and can easily see the other records. CDS is the best option for granular record security.

mdevaney
Super User
Super User

@AppDeveloper 
To let the Admin see all of the gallery records put this code in the OnStart property of your app.

Set(varAdminEmail, "xyz@mycompany.com");

 

And then use this code in the Items property of the gallery

Filter('HUG List',varAdminEmail = UserDetails.Email Or 'Creator Email' = UserDetails.Email)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

good call @mdevaney . I guess it depends on if you have just one admin or multiple admin. Matt's answer is a good one if there is just one admin.

eka24
Super User
Super User

If (User(). Email="xyz@Mcompany.com",
'HUG List',
Filter('HUG List','Creator Email' = User().Email))

 

If you have the admin mail in the created column use:

If ('Created Email'="xyz@Mycompany.com",
'HUG List',
Filter('HUG List','Creator Email' = User().Email))

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

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

Hi @jlindstrom 

 

Thanks for a very important suggestion

Regards

 

@jlindstrom 

I am not fortunate enough to be using CDS but I agree your strategy there is a sound one!

 

To define app roles I typically don't hardcode the admin email into the app.  Instead, I create a SharePoint list of users and their roles then LOOKUP information about the current user's role once the app starts.  Then the app changes what areas the user can access based on the role.

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."


v-yutliu-msft
Community Support
Community Support

Hi @AppDeveloper ,

Do you want to display all data when current user is the admin , display filtered data when current user is not the admin?
Could you tell me how many admins in your issue?

You could decide the app's mode whether for admin when starting the app.

1)If there's only one admin, you should set the app's OnStart:

If(User().Email="xyz@mycompany.com",Set(adminmode,true)
)

2)If there are more than one admins , you should set the app's OnStart:

If(User().Email in ["xyz@mycompany.com","emailaddress2","emailaddress3",....],
Set(adminmode,true)
)

 

Then set the gallery's Items:

If(adminmode,
 'HUG List',
 Filter('HUG List','Creator Email' = UserDetails.Email)
)

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Building on @v-yutliu-msft's idea even further, if "admin" = either owner or co-owner of the app, you can use the PowerAppsforMakers connection to avoid hardcoding e-mail addresses:

 

If(LookUp(
        PowerAppsforMakers.GetAppRoleAssignment("yourappID").value,
        properties.principal.email = User().Email,
        properties.roleName
    ) in [
        "canEdit",
        "Owner"
    ],
Set(adminmode,true)
)

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,503)