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.
Solved! Go to Solution.
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.
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: ""
}
})
Best Regards,
Bof
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
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.
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: ""
}
})
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
@v-bofeng-msft , I need your help please. I have the same issue, where I want to patch the below list, but I do not seem to get the right formula for the AccountMgr_x002e__x002f_Head: (Which is a Person type in the ShP. List)
Patch(
'Emp.Resign-List',
Defaults('Emp.Resign-List'),
{
RequiredStatus:Dropdown3.Selected.Value,
HITSID:HITSIDinput.Text,
Name:NAMEinput.Text,
JobTitle:JOBTITLEinput.Text,
Campaign_x002f_Dept_x002e_:CAMPAIGNinput.Text,
AccountMgr_x002e__x002f_Head:MGRinput.Text})
User | Count |
---|---|
251 | |
102 | |
94 | |
47 | |
37 |