cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Limiting Data Visibility Based On User ID

TL;DR I'm building an app that feeds into a SharePoint list and vis versa.  I'll have multiple users creating rows and list items, but I only want users to see rows and items they've created from within the app.

 

I'm (still) in the midst of creating a prospect tracking app for our sales team.  Our outside reps will log the info of businesses they've contacted out in the field.  Our inside sales rep will follow up on these contacts from our office via phone calls and/or emails.  I'd like all these contacts to be on 1 sharepoint list so that they have a unique ID number.  But I only want the outside reps to have visibility (inside the app) into contacts they have created on list.  Is this possible and how do I do it?

25 REPLIES 25
Highlighted
Dual Super User III
Dual Super User III

Re: Limiting Data Visibility Based On User ID

Users of the app will need full read/write access to the list to run the app.  There are settings in the list that will keep non-admin users from seeing anything other than items they create.  But since you have multiple people who need to be able to see list items that won't work.  Your only real choice is to modify the list item permission on the items themselves to control who can see them.  This has to be done through a series of REST calls sent via HTTP.  Its usually easiest to do this by passing the Item ID to a Flow to change the permissions.  Here's a video that explains how.

https://www.youtube.com/watch?v=_-vvlPXv8rc



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Super User
Super User

Re: Limiting Data Visibility Based On User ID

I do a lot of this in the app. I set the current user variable on app load using Set(_CurrentUser, User()) and then I filter in the gallery for 'CreatedBy'.DisplayName=_CurrentUser 

 

I also do some where it shows everything in the gallery but people can only edit the ones they created or only see certain portions of the data off that same variable.

Highlighted
Helper II
Helper II

Re: Limiting Data Visibility Based On User ID

@rebeccas 

I'm not sure where to enter that info.

When you talk about the app load screen are you referring to Action OnStart?

 

And where do I enter the info to filter the gallery by current user?

 
 
 
Highlighted
Super User
Super User

Re: Limiting Data Visibility Based On User ID

The app OnStart is what I meant to say. On the left side where it list your screens at the top it should sat App if you click on it then at the top you can put in an OnStart value. While testing I normally set that same variable on my Home Screen's OnVisible because the OnStart is harder to test with and make sure it is working.

 

For the Gallery you will do:

 

Items= Filter(DataSource, 'Created By'.DisplayName=_CurrentUser)

 

That will only show items in the gallery that were created by the person logged in.

 

Highlighted
Dual Super User III
Dual Super User III

Re: Limiting Data Visibility Based On User ID

Just to be clear.  That isn't a secure solution.  It filters things displayed in the app, but any user can navigate to the SharePoint list and see all the records.  I am not a big fan of "Security by Obscurity".  Its not really security.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Helper II
Helper II

Re: Limiting Data Visibility Based On User ID

@rebeccas 

I currently have this on Items

SortByColumns(Filter([@'Test 9'], StartsWith(Prospect, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

Test 9 is the list name.  How do I amend this to include the visibility condition?

Highlighted
Helper II
Helper II

Re: Limiting Data Visibility Based On User ID

@Pstork1 

I appreciate the concern.  Fortunately security isn't a top priority.  The filtering accomplishes 2 goals for me

  • Reduction of office/sales rep politics and squabbles
  • Giving the outside reps a quick glance at their own prospecting contacts via the app

While the sharepoint list will technically be visible to the reps, the reps will not be made aware of it's existence and all edits and changes will be logged in a separate excel file.

Highlighted
Community Support
Community Support

Re: Limiting Data Visibility Based On User ID

Hi @bmurphy1 ,

Do you want the Gallery to display items created via the current sign user?

 

I have made a test on my side, please consider take a try with the following workaround:

Set the OnStart property of the App to following:

Set(CurrentUser, User())

Set the Items property of your Gallery to following:

SortByColumns(
               Filter(
                      [@'Test 9'], 
                      StartsWith(Prospect, TextSearchBox1.Text),
                      'Created By'.Email = CurrentUser.Email     // add formula here
               ), 
               "Title", 
               If(SortDescending1, Descending, Ascending)
)

please try a try with above solution, then re-load your app (fire the OnStart property of App), then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Super User
Super User

Re: Limiting Data Visibility Based On User ID

That is true...it won't make it where people CAN'T dig and find that data, just where they won't see it in the app. It isn't a concern for me most of the time...PTO apps and stuff like that it can be.

 

Any...just add an && in that filter and put in the second part:

 

SortByColumns(
Filter([@'Test 9'], StartsWith(Prospect, TextSearchBoxy.Text) && 'CreatedBy'.DisplayName=_CurrentUser),
"Title", If(SortDescending1,Descending, Ascending))

 

You could also just do:

 

SortByColumns(
 Filter([@'Test 9'], StartsWith(Prospect, TextSearchBoxy.Text) && 'CreatedBy'.DisplayName=User().FullName),
 "Title", If(SortDescending1,Descending, Ascending))

 

This second option is if you don't want the variable at the screens start. I normally do that variable and refer to it but if you don't have a ton of data and aren't referring to that information more than once then the second option could work too.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,933)