cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bpark1409
Advocate I
Advocate I

Unable to Patch Empty Fields in Collection created from a SharePoint List

Hi,

 

I have identified an issue with the Patch function - I wasn't sure if this is the correct forum to raise it with Microsoft, but I would be interested to know if anyone else has experienced the same problem and if there is somewhere else where I should be posting this to?

 

Summary

The issue is with using the Patch function to update an empty field in a Collection that was created from a SharePoint Online Custom list - The patch function is only able to update fields that were populated in the SharePoint list when the collection was created.

 

A workaround is to use the UpdateIf function.

 

Steps to reproduce the issues:

 

Create a SharePoint Custom List 'PatchTest' with the default 'Title' column and and additional single line of Text Column called 'TestCol'

 

List DefinitionList Definition

Create 2 items in the SharePoint list - One with the text column ('TestCol') populated and one with it left empty

 

 

List ItemsList Items

Create a blank PowerApp and Connect the SharePoint List as a Datasource

 

 

DataSource.png

 

Create a Collection in PowerApps using the SharePoint List

 

Put the following in the OnSelect Property of a button and use it to create the collection:

 

ClearCollect(colPatchTest,PatchTest)

Confirm the collection has been created:

 

Collection.png

 

Update the record with the Text Column ('TestCol') populated using Patch

 

Put the following in the OnSelect Property of a button and use it to update the first record:

 

Patch(colPatchTest,LookUp(colPatchTest,ID=1),{TestCol: "X"})

Confirm that the record has been updated:

 

Result1.png

 

Try to Update the record with the Text Column ('TestCol') empty using Patch

 

Put the following in the OnSelect Property of a button and use it to try to update the second record:

 

Patch(colPatchTest,LookUp(colPatchTest,ID=2),{TestCol: "X"})

 

Confirm that the record was NOT updated:

 

Result2.png

 

Workaround - Update the record with the Text Column ('TestCol') empty using UpdateIf

 

Put the following in the OnSelect Property of a button and use it to try to update the second record:

 

UpdateIf(colPatchTest,ID=2,{TestCol: "X"})

Confirm that the Record has been updated:

 

Result3.png

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @bpark1409 ,

It is an known issue with Patch function in PowerApps. The user @ChadVKealey has faced same issue with you, please check the response within the following thread:

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/Patch-Problem-Existing-data-updated-new...

 

As an alternative solution, please consider take a try to update your record using UpdateIf function instead of Patch function. Please modify your formula as below:

 

UpdateIf(
colPatchTest,
ID = 2,
{
TestCol: "X"
}
)

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

12 REPLIES 12
RandyHayes
Super User
Super User

@bpark1409 

This is an issue using the Patch function.  Use the UpdateIf function instead.

Take a look at this posting for some more information.

 

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
v-xida-msft
Community Support
Community Support

Hi @bpark1409 ,

It is an known issue with Patch function in PowerApps. The user @ChadVKealey has faced same issue with you, please check the response within the following thread:

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/Patch-Problem-Existing-data-updated-new...

 

As an alternative solution, please consider take a try to update your record using UpdateIf function instead of Patch function. Please modify your formula as below:

 

UpdateIf(
colPatchTest,
ID = 2,
{
TestCol: "X"
}
)

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xida-msft,

 

Thanks for confirming that this is a known issue.

 

FYI - I included the use of UpdateIf as a workaround within my  original post.

 

Regards.

I've just spent a few hours diagnosing this problem and finally concluding it must be a bug in the Patch function.  A quick search confirmed my hunch. So thanks to all for posting both the issue and solution.

 

Hmmm ... Some 4 months on since this was raised and this is still a production bug! 😞

GregLi
Power Apps
Power Apps

We believe we have fixed this issue with version 3.20051.16, available with the Frequent cadence in some regions such as Canada.  It will be rolling out to everyone soon.  Please give it a try and let us know if you still see an issue.

Tapesh
Post Prodigy
Post Prodigy

hi @GregLi  @bpark1409 

 

I have the same related issue can you please help on this as well if you can thanks sir 

 

Please see the link below 

 

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/How-to-Increase-value-by-1-number-ignore-if-... 

@GregLi 

 

This is most certainly not working for me... what is the expectation here? Are we supposed to now be able to update a collection or a SharePoint list row using Patch and revert a numeric column to be blank? I tried all the usual ways of doing this and could not achieve using a SharePoint number column, with no default value set (in SharePoint). Cannot set to Blank() or "".

@PhilD 

Yes, this works fine.

Make sure you have "Formula-level error management" feature turned on in your Advanced Settings.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Oh, okay, thanks @RandyHayes ... is this required for this feature to work? I will try that when I get a chance. Thanks for clarifying the expectation... I'll report back and confirm that this works after I turn this on and test.

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,167)