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 Definition
Create 2 items in the SharePoint list - One with the text column ('TestCol') populated and one with it left empty
List Items
Create a blank PowerApp and Connect the SharePoint List as a Datasource
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:
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:
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:
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:
Thanks.
Solved! Go to Solution.
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:
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,
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.
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:
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,
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! 😞
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.
I have the same related issue can you please help on this as well if you can thanks sir
Please see the link below
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 "".
Yes, this works fine.
Make sure you have "Formula-level error management" feature turned on in your Advanced Settings.
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.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
201 | |
183 | |
69 | |
43 | |
34 |
User | Count |
---|---|
341 | |
268 | |
114 | |
66 | |
66 |