cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Meneghino
Community Champion
Community Champion

Bug report: Patch function not working as expected when merging records

In the following expression, the first Patch function works, but the other two do not.

Clearly this is a bug, since the first argument of Patch can be a record or a table/collection.  Please see highlighted error.

 

__.JPG

 

Any ideas welcome.

7 REPLIES 7
v-micsh-msft
Community Support
Community Support

Hi @Meneghino,

 

Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])

DataSource – Required. The data source that contains the record that you want to modify or will contain the record that you want to create.

I think you might missed some points, the first argument could be a datasource, or a collection.

Some more information:

"

In your app, you'll use formulas to create, update, and manipulate records and tables. You'll probably read and write data to an external data source, which is an extended table. In addition, you might create one or more internal tables, which are called collections.

"

See: Understand tables and records in PowerApps

Please try to add table function with the Current_A (and current_B), see if that would help.

Regards,

Michael

 

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

Hi @v-micsh-msft, thanks for getting back to me.

Please see documentation here.

It clearly states: "Even if you're not working with a data source, you can use Patch to merge two or more records"

The syntax is explained in the page and states: Patch( Record1, Record2 [, …] )

It works in the first instance but not in the other instances of my example.

 

Thanks for the remindings.

My bad.

I will take some tests from my side and update later.

Regards,

Michael

 

 

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

Hi @Meneghino,

 

See the test results:

18.PNG

 

No corresponding errors popped out from my side.

Would it be related to the collection name?

May you take a try to change the two collection names without the "_"?

Regards,

Michael

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

I'm experiencing something very similar, where a patch call is changing the type of the context variable to be a datasource/collection, which conflicts with all uses of the variable, since it is indeed just a record.  If I remove the call, it will re-evaluate and treat the variable as a record, and then paste back in, it will again, treat it as a record and the app will work.  Saving the app will not fix the issue going forward.

Did you get your issue resolved?

 

Did you find a work around?

As a work-around, have you tried creating a collection, populating it with your context variable, performing the patch on the collection and then assigning the one row of the collection back to the context variable (using First or LookUp to return a record datatype)?

@PaulD1 I saw that in another location in the app, I bet that is why and I bet it would work.  My current work around is to do another lookup for the object out of the gallery.

 

I'm currently fighting for this to be considered a bug, and for it to get prioritized.  

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (6,319)