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

allow user to edit only his own row on sharepoint list

hello,

i have a sharepoint list where every row has data related to unique user specified with the person column. The person column allow me to access the data from office users, including picture, email and so on. This way i can also add more data in other columns.


in my power app i want everyone to be able of searching data, but editing only their own data. I made a Profile screen for that. 

 

In a simple app i can just edit any row with a form retrieving the item from gallery.selected value... 
how can i show the edit form showing as item the values from the row matching with the User().email ? 

thanks

8 REPLIES 8
indhaa
Super User
Super User

Hi

 

On App OnStart Property , you can get the user details to a variable 

Set(
LogInUserMail,
Office365Users.MyProfile().Mail
),

 

Then you can compare this variable with user who created the record. Only visible the Edit icon or enable the icon if the record matches the user.

 

 

oh yes i did something similar onStart i made a myEmail using User().email. is that ok? My problem i think is that i don't know how to compare this variable with the rows value. I mean, normally i'd do a for loop to scroll the values of my data, but i have no idea how to do this with powerapp on sharepoint 

Silvester
Super User
Super User

Hi @Antonioclk ,
Set the Edit button or icon visible property to

User().Fullname=ThisItem.'Created By'.DisplayName

This return a boolean, false if the record doesn't belong to the user, true and set the edit button visible for the user to make the changes if it belong to the user.

Kindly accept this as a solution if it works for you.


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the thread and so other members of the community can find it easily.

sadly it won't work. i maybe didn't explain myself correctly.

I have a screen A with a gallery showing elements from my sharepoint. Anyone can click on a row and access a screen B showing details of the items.
On the top bar i have a profile icon linked to a screen C with an edit form. Here i should fill the form with data coming from the row related to the User.

The sharepoint is done by HR staff, while user can be any employee. Every row is a different user, and in the columns i have User (person type column), email (text column) location and so on.

So i guess i need to link my edit form to the sharepoint, filtering it by the email that i get from User().email
but i don't know how to do such filter, i guess i should add something into the Item property of the edit form, but what? I come from programming so sometimes this gets kinda confusing for me 😄

my first idea was to put in Item property something like lookup(mySource, User.Email = User().Email) but it doesn't work

Hi,

 

So I don't have a picture of how your Form is set since the explanation a little vague for me.

So I'm giving three scenarios. Hope it helps

 

1. Anyway, I'm assuming when user login to a Form, it will show different section. One for HR personnel and others user section. I'm assuming I can only edit my details and not the HR section. If section is containers, you can set it as below on the property of the containers, otherwise on the datacard.

 

So assuming my email details is already in the column of SP List. So when you click on the record of the gallery, it will open the record.

 

On App OnStart Property , you can get the user details to a variable 

Set(
LogInUserMail,
Office365Users.MyProfile().Mail
),

 

So on the DataCard DisplayMode property for the User section you can set as 

If(DataCardX.Text = LoginUserMail, Edit, Disabled)

 

For HR Users, assuming users in Office365 group, for the relevant HR section you can set the Data card display mode property as below

If(LogInUserMail in Office365Groups.ListGroupMembers("xxx-xxx-xxx-xxx-xxx").value.mail, Edit, Disabled) 

 

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

 

2. If the Edit Icon is on the Gallery, you need to set the Edit button or icon visible property to

LoginUserMail=ThisItem.'SP Column Name with EMAiL '

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

3. If the Edit Icon is on the Form itself, then on the Visible property of  the Edit icon or DisplayMode property

If DisplayMode Property
If(DataCardX.Text = LoginUserMail, Edit, Disabled)

OR

If Visible Property
DataCard.Text = LoginUserMail


 

Hope it helps

 

thank you for your time, sadly the solution didn't include my scenario. I'll try to better explain.

my app should list people, show details of people to every user but allowing each user to edit only his own data. The data is stored on a Sharepoint list.

 

The sharepoint list has the following fields:

  • User - Persony ColumnType 
  • City - Location ColumnType
  • WorkPhone - Text ColumnType
  • Whatsapp - Text ColumnType

The app has 3 screen:

  • Main - it's made by a NavBar with a title label and a UserProfile icon who lets you navigate to the Profile screen. There is also a gallery loaded with the Sharepoint Connector. Clicking a row will open the Detail screen.
  • Detail - it's a simple display form loaded with Gallery.selected
  • Profile - it's a simple edit form. The form should load the data of the row related to the logged in user. 

My problem is i can't load the user data in the edit form, maybe i'm not doing it correctly.

 

My idea was to set the Item property of the edit form with a LookUp function, where i would match the email of the logged in user, with the email retrieved by the user.email data of the column in SP.

LookUp(MyData,User().Email=User.Email)

it wasn't working.

 

right now while writing this post, i reloaded the page, after 2 days i keep trying this, and it just worked... how can that be possible????

I think your code was wrong then and now it is correct. Maybe you made a correction to it and after that it is working? Most likely scenario 😊

LookUp(MyData,User().Email=User.Email)


It should be 

LookUp(MyData,User.Email=User().Email)

 

that's super weird... i just refreshed the page 😄

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (3,885)