DatasetModel:SaveChanges
 
Forums / SmartComponent Library - Developer Forum / DatasetModel:SaveChanges

DatasetModel:SaveChanges

6 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    08 Nov 2019
    Link to this post

    We have added unbound fields to some of our TT as a way to flag our backend to NOT to do certain things. For many of our tables we create an xml message and send it off to SonicMQ. There are times where we do not want to do this. This flag field can tell the backend to NOT send the xml message. This does what we need but does not help us if we delete the record. I noticed there is an OVERLOAD for SaveChanges where I can pass a Progress.Lang.Object. What exactly is this OVERLOAD used for? Can I use it like we do when calling InvokeTask? Any doc examples?

     

    Thanks in advance.

  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    08 Nov 2019 in reply to Roger Blanchard
    Link to this post

    The optional argument to SaveChanges can be used exactly for that purpose.

    Within the Business Entity, it's accessible as THIS-OBJECT:SaveChangesParameter

  3. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    08 Nov 2019 in reply to Mike Fechner
    Link to this post

    Hey Mike,

    Thanks for responding. I did see that last night and have that working by casting that over to my parameter object. I then need to get that parameter reference into my DataAccess class so I am casting THIS-OBJECT:DataAccessObject to my DataAccess Object class and then pass the parameter object.

    It all seems to work. The only thing I noticed is the DataAccessObject property is not valid in the BE and I have to use THIS-OBJECT:InitializeDataAccessObject (). Does that seem correct?

  4. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    Answered
    08 Nov 2019 in reply to Roger Blanchard
    Link to this post
    In this case, you should override the InitializeDataAccessObject method and pass on the reference after the SUPER:InitializeDataAccessObject 
  5. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    08 Nov 2019 in reply to Mike Fechner
    Link to this post

    Great...thanks.

     

    I will give that a try.

  6. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    08 Nov 2019 in reply to Mike Fechner
    Link to this post

    Okay, I have this working.

    I added the following to the InitializeDataAccessObject OVERRIDE after SUPER.

     

    DO ON ERROR UNDO, THROW:
       
       /* Roger Blanchard / Osprey Retail Systems Nov 8, 2019
        Lets call SetParameterObject in our DataAccess Object and pass our
        SaveChangesParameter so the DataAccess Object has access to it.
       */
       
       CAST (THIS-OBJECT:DataAccessObject, Osprey.CustomClasses.OERA.IOspreyDataAccess):SetParameterObject(THIS-OBJECT:SaveChangesParameter) .
       
       CATCH e AS Progress.Lang.Error:
        LogManagerWrapper:WriteError(e).
       END CATCH.
      END.

     

    I did also have to add the following to the SaveChanges OVERLOAD before SUPER. If on the client we used SaveChanges (oParameter) and then later used SaveChanges() the parameter object on the backend was still valid. The code below will clear the reference.

    IF VALID-OBJECT (THIS-OBJECT:DataAccessObject) THEN
      DO ON ERROR UNDO, THROW:
       
       CAST (THIS-OBJECT:DataAccessObject, Osprey.CustomClasses.OERA.IOspreyDataAccess):SetParameterObject(THIS-OBJECT:SaveChangesParameter) .
       
       CATCH e AS Progress.Lang.Error:
        LogManagerWrapper:WriteError(e).
       END CATCH.
      END.

     

    THANK YOU!!

6 posts, 1 answered