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

4 REPLIES 4
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

View solution in original post

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.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (888)