cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vquangle
New Member

Patch function adding new unwanted records

Hello,

 

So I am working on an app that "OnChange" of a particular input on the gallery it will select the parent gallery which has the following parent gallery which has the follow parent code:

 

Patch(colLots, ThisItem,

{
LabID0: LookUp(colLabs, Labs = LotEdit_Labs.Selected.Labs, LabID) ,
SectionID0: LookUp(colSections, Sections = LotEdit_Section.Selected.Sections, SectionID),
SubSectionID: LookUp(colSubSections, SubSection = LotEdit_SubSection.Selected.SubSection, SubSectionID),
ItemID: varThisItem.ItemID,
LotNumber: LotEdit_LotNo.Text,
Expiration: LotEdit_Exp.Value,
QTY: Value(LotEdit_QTY.Text),
Active: LotEdit_ActiveStatus.Checked,
Preview: LotEdit_PreviewStatus.Checked,
StorageID0: LookUp(colStorage, StorageLocation = LotEdit_Storage.Selected.StorageLocation, StorageID)
}

)

 

However, I am noticing that when I change the input on an existing record it will change the current record, but also duplicate and add another record as well. Correct me if I am wrong, but shouldn't the only record being change be "ThisItem" only? Also, this happens intermittently! And is not consistent so it's nearly impossible for me to pinpoint the cause. Sometimes it will work perfectly fine and sometimes it will decide to just add a new unwanted record...

 

Thanks in advanced!

2 REPLIES 2
BCBuizer
Super User
Super User

Hi @vquangle ,

 

You will still have to link ThisItem to the item in your datasource

 

Patch(
          colLots,
          LookUp(colLots, 'Unique Identifier Column' = ThisItem.'Unique Identifier Column'),
          {...........
)

 

 

 

Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
ansrikanth
Resolver III
Resolver III

Hi @vquangle 

 

Run the app in the editor (play from the editor basically), and use the monitor to see what are all the updates happening to your collection. Monitor is the big help for me in many of the scenarios like this.

 

Thank you

-Srikanth

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,735)