cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AtomicPete
Frequent Visitor

Patch to a sharepoint Person Column with only the persons email address to start with.

I have a form with a textinput box that will contain the email address of one of my organisations Office365 users.

 

I need to use the Patch function to patch this textinput box to a new record in a sharepoint list person column. This column should record the user who's email address was in the textinput box but I get an error message about the argument not matching the record type. I have tried both of the following approaches with the Patch function unsuccessfully.

 

Patch('MyList', Defaults('MyList'), Employee: UserEmailTextInput.Text)

 

Patch('MyList', Defaults('MyList'), Employee: Office365Users.SearchUser({searchTerm:UserEmailTextInput.Text}).DisplayName)

 

Neither works. Any solutions much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @AtomicPete :

Could you tell me if the Employee field allows multiple selections?

I assume Employee do not allows multiple selections.

Firstly, I want to explain why you can not update the Employee field.

The point is you need to use a specific array to update the person field.

Secondly,please try this solutin:

1\add an Office365 users connection.

1.JPG

2\please try this code

 

Patch('MyList', Defaults('MyList'),{Employee:{
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            Department: "",
            Claims: "i:0#.f|membership|" & UserEmailTextInput.Text,
            DisplayName: Office365Users.UserProfileV2(UserEmailTextInput.Text).displayName,
            Email: UserEmailTextInput.Text,
            JobTitle: "",
            Picture: ""
        }
})

 

2.JPG3.JPG

Best Regards,

Bof

View solution in original post

5 REPLIES 5
ZabiBabar
Continued Contributor
Continued Contributor

Hi @AtomicPete ,

 

 I think you are on the right track with this:

Patch('MyList', Defaults('MyList'), Employee: Office365Users.SearchUser({searchTerm:UserEmailTextInput.Text}).DisplayName)

 

Maybe you can try:

Patch(
  'MyList', 
  Defaults('MyList'), 
  Employee: First(Office365Users.SearchUser({searchTerm: UserEmailTextInput.Text})
  )
)

 
However, I am not aware what is required to create an employee of people type. You can take a look at this link to see how you can patch people field. https://www.about365.nl/2018/11/01/handling-sharepoint-lookup-and-people-fields-in-powerapps/

Scroll down to patching people fields!

 

Best,
Zabi
Mark this post as a solution, or kudo it if you found it be helpful. You can choose more than one answers as solutions, including your own answer. 🙂

Hi @AtomicPete 

 

To Patch to SharePoint person column you need to provide specific object for person type column

 

Check this video

https://www.youtube.com/watch?v=g9ChYuTdNd4

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Thanks,
Reza Dorrani, MVP
YouTube
Twitter

v-bofeng-msft
Community Support
Community Support

Hi @AtomicPete :

Could you tell me if the Employee field allows multiple selections?

I assume Employee do not allows multiple selections.

Firstly, I want to explain why you can not update the Employee field.

The point is you need to use a specific array to update the person field.

Secondly,please try this solutin:

1\add an Office365 users connection.

1.JPG

2\please try this code

 

Patch('MyList', Defaults('MyList'),{Employee:{
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            Department: "",
            Claims: "i:0#.f|membership|" & UserEmailTextInput.Text,
            DisplayName: Office365Users.UserProfileV2(UserEmailTextInput.Text).displayName,
            Email: UserEmailTextInput.Text,
            JobTitle: "",
            Picture: ""
        }
})

 

2.JPG3.JPG

Best Regards,

Bof

Thanks @v-bofeng-msft ,

 

Your first section of code worked. I was not aware that the people columns in a Sharepoint list require such a complicated bit of code to patch to. All working now.

Your video was awesome regarding Patching to a Person Column. But in the case of let’s say an ‘Admin List’ - and I want to patch users to that list who should have Admin Access, how can I patch other users names to that Admin List using the Person Column?

Any help is much appreciated!

Thanks!

Jason

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,760)