How do I allow users to only view/edit/delete records they created themselves?

4.3k views Asked by At

Using MS PowerApps how can I make it so that a user can create records, but only view/edit/delete records they created themselves, i,e not see any records created by other users.

Furthermore can this be group based? so two users that belong to to the same group can view/edit/delete records created by users in the same group?

there is not a lot of documentation about this, the only docs I have find specify User access to entities, but I need more granular access than that.

3

There are 3 answers

7
Reza On

This is not supported today. We are thinking about scenarios like this. Please add your request to https://aka.ms/powerapps-ideas

Depending on the back end that you are using you might be able to work around this limitation by making sure that your back end returns rows that are belong to the current user, and rejects edits when user doesn't have permission. However, this can be very complex, and not possible for services like SharePoint.

0
Kobi Rivlin On

I have created a vacation app that uses SharePoint as a data source and allows users to create vacation requests, but only view\edit pending requests they created and requests of their direct reports. The way it was created:

  1. Homepage has buttons with label of the views: New Request, My Requests & Direct Reports Requests

  2. Each button performs two actions: 1. Setup a variable numeric value for the choice. 2 Navigate for the list view

  3. Elements of the list page change based on the variable value: Sorting filters: "If(variable=1,SortByColumns(Filter(VacationRequests, Author.DisplayName = User().FullName),"ID", If(SortDescending1, Descending, Ascending)), variable=2,SortByColumns(Filter(VacationRequests, Vacation_x0020_Request_x0020_Sta = "approve"),"ID", If(SortDescending1, Descending, Ascending)), variable=3,SortByColumns(Filter(VacationRequests, Approving_x0020_Manager.DisplayName = User().FullName),"ID", If(SortDescending1, Descending, Ascending)))"

Label changes based on value:

"If(variable=1,"My Requests",variable=2,"Approved Vacations",variable=3,"Direct Reports")"; background fill color of top rectangle also change based on values: "If(variable=1,RGBA(246, 88, 16, 1),variable=2,RGBA(99, 139, 44, 1),variable=3,RGBA(0, 121, 187, 1))";

End result is that users can only view\edit\delete only items from views\filters they can see.

0
PTansey On

Doesn't it depend on your data source? I'm using a SharePoint list and I've been able to successfully change the BrowseGallery filter to only show list items the current user created.

  1. Screen.OnVisible = UpdateContext({UserEmail: User().Email})
  2. Then I changed the BrowseGallery.Items to include a filter of Author.Email = UserEmail (yes, we have to use Author instead of CreatedBy)