cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper V
Helper V

Patch function doesn't work with Person/Group field - NewForm

Hi,

 

I have designed a Powerapps form with SharePoint as the datasource. Mostly in my form, I have used field from SharePoint as the datasource.

 

I have added an additional field (combobox) from Powerapps, for which i should save the selected value into the Person field in SharePoint.

 

Hence in NewForm, OnChange of that field, I have written below Patch function.

 

Patch('DS',NewForm.LastSubmit,{'Registrar':DataCardValue15_1.Selected});

 

However, when i submit the form, the field value doesn't gets saved into SharePoint. I have used the same Patch function even in OnSuccess of the form, still cannot save.

 

Any advice please

 

 

 

 

3 REPLIES 3
Super User II
Super User II

To patch LookUp fields to SharePoint, you need to include the following attributes:
1. '@odata.type',
2. Id and
3. Value

1. '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"

2. Id: ID of the record

3. Value: Value of the record

Here is an example from one of the online blogs, include this in the Patch function:

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id:Gallery1.Selected.ID,
Value:Gallery1.Selected.Title}
}

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com

@Kumar9024021 

 

@PowerAddict  suggested you to included odata.type

 

In our case we usually notice faster performance when leaving odata.type out. Especially when for instance, Patching the record. If we leave it in, it is much slower. If we leave it out, it is much faster. It usually works when we leave odata.type out as well.

 

However @Kumar9024021 if it only works for you using that odata.type, then you may need to use it that way. Maybe in some cases it has to be there. When we do Patch we take it out and the performance is at least 10x better. There is noticeable lag in our case if we leave odata.type in there, and it works correctly and much better without it - however it may depend on your case.

 

 

Community Support
Community Support

 will@Kumar9024021 

Does the additional field (combobox) locate inside the Form?

What is the Items property of combo box?

 

If the field is in the form, there is no need to use patch function. 

1. set the combo box items: Choices('DS'.Registrar)

2. set the Update of data card: DataCardValue15_1.Selected

when you submit the form, the selected person will be saved into the list.

 

If the field is outside the form,  I follow your formula and it can work well, so please follow my steps and check if there is any difference from yours.

1. set the combo box items: Choices('DS'.Registrar)

2. set OnSuccess of Form: Patch('DS',NewForm.LastSubmit,{'Registrar':DataCardValue15_1.Selected});

3. set submit button OnSelect: SubmitForm(NewForm)

Note: you can not use NewForm function before Patching the selected person, because once NewForm is executed, the NewForm.LastSubmit will be empty.

Snipaste_2020-01-14_15-15-03.pngSnipaste_2020-01-14_15-15-18.png

Sik

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,498)