DatasetModel Class - Cancel changes
 
Forums / SmartComponent Library - Developer Forum / DatasetModel Class - Cancel changes

DatasetModel Class - Cancel changes

3 posts, 0 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    381 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.
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    22 Oct 2020 in reply to Roger Blanchard
    Link to this post
    If I understand your demand correctly, you should be able to call

    poPhysicalInv:BufferHandle:REJECT-ROW-CHANGES () . 

  3. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    23 Oct 2020 in reply to Mike Fechner
    Link to this post
    I will give that a try...thanks.
3 posts, 0 answered