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

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

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

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
dynamicsedge
Level 8

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

@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.

 

 

Microsoft v-siky-msft
Microsoft

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

 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
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,338)