cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
KroonOfficeSol
Level 10

Patch() is broken

Yesterday I needed five hours to get a problem fixed and found out my problem came from a not working Patch() formula.

 

My solution:

Step 1: First I set parameters and run a flow which returns a record. 

Set(MyPost, First(Flow.Run()))


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

 

Paul

 

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 ;-)

1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Level 10

Re: Patch() is broken

Re-building the app in a new canvas was the solution here ;-)

5 REPLIES 5
Super User
Super User

Re: Patch() is broken

Hi Paul,

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?

 

Community Support Team
Community Support Team

Re: Patch() is broken

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:

If(
MyPost.GUID in MyCollection.GUID,
Patch(
_MyColllection,
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 */
Column2: MyPost.Column2,
...
}
),
Patch(
_MyColllection,
Defaults(_MyCollection),
{
Column1: MyPost.Column1,
Column2: MyPost.Column2,
...
}
) )

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

More details about Patch function, please check the following article:

Patch function

 

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.
KroonOfficeSol
Level 10

Re: Patch() is broken

@timl 

 

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.

 

Greatings,

Paul

KroonOfficeSol
Level 10

Re: Patch() is broken

@v-xida-msft 

 

He Kris,

 

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.

 

Greatings Paul 

KroonOfficeSol
Level 10

Re: Patch() is broken

Re-building the app in a new canvas was the solution here ;-)

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 70 members 4,371 guests
Please welcome our newest community members: