cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Patch an Item from SharePoint in PowerApps by adding a Person to a Person-Type column where multiple selections are allowed

Hi,

I wanted to add a person (in my case a passenger) to a column Person Type by pressing a button in Powerapps. In Sharepoint, the column allows multiple people in a record.

I wanted to use the Patch() function and add the user with the User() function when the button is pressed.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous 

 

If you want add data to existing data, then you may want to take few extra measure, please follow the below expression:
 
ClearCollect(ExistingUsers,Table({'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:"i:0#.f|membership|" & User().Email,
    Department:"",
   DisplayName:User().FullName,
         Email:User().Email,
      JobTitle:"",
       Picture:""
   }),LookUp(SPListName,Title = "test").PersonField);
   Patch(SPListName,LookUp(SPListName,Title = "test"),{PersonField:ExistingUsers})
 
Here, we are creating a collection of the users that already exist as part of the record and adding current user value to it. Then finally this created collection is passed a Person field when patching an update to the record.
 
Hope this helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

6 REPLIES 6

Hi @Anonymous 

 

You can add the current user as a person field in your SharePoint List by using the below expression:
 
Patch(SPListName,Defaults(SPListName),{Title:"Test3456760",PersonField:Table({'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:"i:0#.f|membership|" & User().Email,
    Department:"",
   DisplayName:User().FullName,
         Email:User().Email,
      JobTitle:"",
       Picture:""
   })})

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Anonymous
Not applicable

This didn't work for me because I dont have a UserList. All users are Office 365 Users.

Hi @Anonymous 

 

Can you share more details about the UserList that you are referring to? All the Office365 users are by default present in the sharepoint Person type field. Are you getting any error when using the above formula?
Anonymous
Not applicable

hi @yashag2255 ,

Now I can add add a user to the record, but only one. if I have already an user (or more) in the record it deletes it/them.

Hi @Anonymous 

 

If you want add data to existing data, then you may want to take few extra measure, please follow the below expression:
 
ClearCollect(ExistingUsers,Table({'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:"i:0#.f|membership|" & User().Email,
    Department:"",
   DisplayName:User().FullName,
         Email:User().Email,
      JobTitle:"",
       Picture:""
   }),LookUp(SPListName,Title = "test").PersonField);
   Patch(SPListName,LookUp(SPListName,Title = "test"),{PersonField:ExistingUsers})
 
Here, we are creating a collection of the users that already exist as part of the record and adding current user value to it. Then finally this created collection is passed a Person field when patching an update to the record.
 
Hope this helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Anonymous
Not applicable

This worked. Thank you kind stranger.

The only thing: i replaced 

Title = "test"

with

ThisItem

because i worked in a form.  

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,516)