Roger Blanchard
447 posts
Registered:
29 Jun 2018
21 Sep 2020
Link to this post
I have a dataset model class that I am using to update a group of records.
It has two two tables PhysicalInv and PhyLine. The PhysicalInv is the parent with the PhyLine the child (one to many).
I am using the code below to fetch the one PhysicalInv record and all of the PhyLine records.
oPhysicalInv = NEW Osprey.Pos.PhysicalInv.PhysicalInvDatasetModel ().
// set filters
oPhysicalInv:PhysicalInv:Filter:RunNum:EQ(poParam:RunNum). // The RunNum we are posting
oPhysicalInv:PhysicalInv:FillPhyLine = TRUE.
// oPhysicalInv:PhysicalInv:FillChildTables = "ePhyLine":U. // we want ALL PhyLine records as well
oPhysicalInv:BatchSize = 0. // we want ALL records not just default of 100
oPhysicalInv:PhysicalInv:Fill().
I am then looping through the PhyLine records, updating them and then calling Savechanges. If Savechanges fails (validation, etc.) is there a way to Cancel the changes for this one record? I want to log the error and continue processing the remaining records.
DO WHILE oPhysicalInv:PhyLine:Available:
// code that updates PhyLine record
poPhysicalInv:SaveChanges().
// save changes
oPhysicalInv:PhyLine:GetNext().
END.