cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jhumml
Level: Powered On

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
Dual Super User
Dual Super User

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

Hi @jhumml 

 

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
Dual Super User
Dual Super User

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

Hi @jhumml 

 

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!

jhumml
Level: Powered On

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

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

Dual Super User
Dual Super User

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

Hi @jhumml 

 

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?
Highlighted
jhumml
Level: Powered On

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

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.

Dual Super User
Dual Super User

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

Hi @jhumml 

 

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

jhumml
Level: Powered On

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

This worked. Thank you kind stranger.

The only thing: i replaced 

Title = "test"

with

ThisItem

because i worked in a form.  

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,708)