Yesterday I needed five hours to get a problem fixed and found out my problem came from a not working Patch() formula.
Step 1: First I set parameters and run a flow which returns a record.
Step 2: To update I use this formula
If(MyPost.GUID in MyCollection.GUID ,Patch(_MyColllection, LookUp(MyCollection, GUID = MyPost.GUID), MyPost) ,Collect(_MyColllection, MyPost) )
This is a properly formatted formula, right. Only Step 2 failed on the patch() formula. PowerApps seems to think it works and gives no error but doesn't update either.
PowerAppsTeam, could you please look into this? Thanks
For those who read this and has the same issue: I got to a workaround to fix it for now, by modifying the formula like this:
If(MyPost.GUID in MyCollection.GUID ,Collect(_MyColllection, LookUp(MyCollection, GUID = MyPost.GUID) ;Collect(_MyColllection, MyPost) ,Collect(_MyColllection, MyPost) )
So you don't wasted hours as I did 😉
Solved! Go to Solution.
I'm just looking at your formula and I'm a bit confused, so could you clarify how your code should work?
Here, you're checking that the record that you retrieve from Flow exists in MyCollection.
If(MyPost.GUID in MyCollection.GUID ,Patch(_MyColllection, LookUp(MyCollection, GUID = MyPost.GUID), MyPost)
If the record exists , you want to update the record that exists in _MyColllection (ie, the collection that begins with _My). If, however, the record doesn't exist in the _My collection, they'll be nothing to patch and I think that's why you see the behaviour you see.
Could you confirm that MyCollection and _MyColllection are always in sync to avoid this scenario?
HI @KroonOfficeSol ,
Do you want to check if the GUID has been existed within your _MyCollection, if yes, update the existing record, otherwise, patch the record into your _MyCollection?
I have made a test on my side, please consider take a try to modify your formula as below:
MyPost.GUID in MyCollection.GUID,
LookUp(_MyCollection, GUID = MyPost.GUID), /* <-- Please type _MyCollection rather than MyCollection */
Column1: MyPost.Column1, /* <-- Provide proper column values from MyPost reocrd for the correspodning columns in your _MyCollection */
Please take a try with above formula, then check if the issue is solved.
More details about Patch function, please check the following article:
Sorry for the late respons.
To answer your question, that's why I use the Collect() formula on the false part. SO if there is no record I add it to my collection.
Sorry for my late response.
Thanks for your input, but this can't be the way to go here. There something not working with the Patch() formula which should do it properly in the way I build it. You can see in my post I found a simple workaround for the issue (I think far easier than your approach ;-), but still it's not like it should be.
I tried to simulate the issue in a new app, where it seems to work like a charm. I was not able to find the source of the issue in the current app, so I think maybe there is something wrong in the core of my app. I am building on the solution for over six months now and in that time a lot has changed, asswel in PowerApps as in my App design. So I decided to re-build my app in a few hours.
Learn how to create your own user groups today!
Check out the new Power Platform Community Connections gallery!
Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.