cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

BUG REPORT - Duplicate patch functions firing in Datatable OnSelect

I see some reference to OnSelect functions firing twice, I am trying to patch data to a SharePoint source OnSelect, here is my code: 

If(DataTable7.Selected.status = "Needed", Set(NextAvailableID, First(Sort(Repair, ID_Repair, SortOrder.Descending)).ID+80);
Patch(Repair, {SerialNumber: DataTable1.Selected.SerialNumber, ID_Repair: NextAvailableID, RepairComments: "test"});Patch(ProcessedECO, {RepairID: NextAvailableID, ProECO_DateComplete: Today(), ProECO_Initials: User().FullName, ECONumber: DataTable7.Selected.ECONumber});  Navigate(PatchSingleECO, Fade), Navigate(RepairDetails));

Both "Repair" and "ProcessedECO" are SharePoint data sources, records are being created twice when this fires. I have tried with/without the defaults() parameter as I thought that was the cause, but no luck.  Is this in fact a bug, and is there an ETA on a resolution?  The similar tickets I only see reference to it being a bug and to report it. 

 

7 REPLIES 7
Super User III
Super User III

@Sheff 

What are you trying to do: add a record or update a record?  The Patch function typically has three arguments:

 

PATCH(datasource, record, {update})

 

In your Patch function I only see two arguments:  datasource and record.  Maybe this is why your code is not working?

 

//your code
Patch(Repair, {SerialNumber: DataTable1.Selected.SerialNumber, ID_Repair: NextAvailableID, RepairComments: "test"});

//my annotation
Patch(Repair,missing_record_argument,{SerialNumber: DataTable1.Selected.SerialNumber,ID_Repair: NextAvailableID, RepairComments: "test"});

 

To add record you would typically this.

Patch(Repair,Defaults(Repair),{SerialNumber: DataTable1.Selected.SerialNumber,ID_Repair: NextAvailableID, RepairComments: "test"});

 

To update a record would depend on how your app is built.  You'll have to let us know whether you want to Add or Update.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

@mdevaney  thanks for the help.  I mentioned in the post I originally had the defaults() argument for both patch functions, I have put them back in and confirmed that duplicate records are still being created in both data sources. It is also incrementing the NextAvailableID so it appears the entire OnSelect is firing twice.

@Sheff 

Thanks for trying the 1st idea Sheff.  Problem solving is often a process of elimination so I wanted to remove that possibility before we go further.

 

My next question is, does the screen navigate to this once the PATCH is done?

Navigate(PatchSingleECO, Fade)

 

Check the onVisible property of that screen.  Any code there?  Moving to a new screen triggers the execution of any code in onVisible.

 

Yes it navigates correctly, I tried a few different test screens to make sure it wasn't anything caused by the datatable on that destination screen. When I get back in front of a machine I will add the patch functions to a button and see if it still duplicates the records. Thanks for the assistance.

@Sheff 

OK. Once you've tested some more come on back to the forums if you need a brainstorming partner.

@mdevaney  so I copied the code above but removed the If Statement from the datatable Onselect, and put just the patch functions on a button and they created the expected single record. Then to test, I removed the IF statement from the Datatable OnSelect thinking it may have contributed to the duplicates, however duplicate records are still being patched in both data sources even without the IF statement. I also manually set the repairID to rule out issues with that, and still 2 records are created. Something about the Datatable Onselect is making it execute twice.  It seems this has been reported before, the fact that this was posted nearly a year ago is troubling.  

 

 

@Sheff 

Oh no, that's not good...  might as well go ahead and report it but... that sucks.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (22,437)