DataAccess Class Validation Hooks
 
Forums / SmartComponent Library - Developer Forum / DataAccess Class Validation Hooks

DataAccess Class Validation Hooks

6 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    13 May 2021
    Link to this post
    Should the before buffer field values be the same in the ModifyBeginTrans and ModifyEndTrans methods?

    The reason I am asking is I just noticed for one of our BE that the before values are changing to the after values in the ModifyEndTrans. It appears it has something to do with the ReceiveData method in the BE.

    If I comment the updating the eOrderLine.ItemDescrpt then the values in the BeginTrans and EndTrans are the same. 

    /*------------------------------------------------------------------------------
            Purpose: Provides a hook to modify data in the ProDataset after Read and 
                     Update operations (i.e. population of aggregated values)                                                                     
            Notes:   Invoked during FetchData () and SaveChanges ()                                                                     
        ------------------------------------------------------------------------------*/
        METHOD OVERRIDE PUBLIC VOID ReceiveData ():

    /* Roger Blanchard / Osprey Retail Systems May 13, 2021
    I had to add a JOIN to the Item table to populate this as updating
    the eOrderLine table here appears to cause the before table values
    to be different in the ModifyEndTrans 
    */

    /*   
        FOR EACH eOrderLine:

        IF eOrderLine.ItemDescrpt EQ "" THEN 
        FOR FIRST ITEM NO-LOCK WHERE Item.ItemNum = eOrderLine.ItemNum
        AND ITEM.PackNum = eOrderLine.PackNum: 
        eOrderLine.ItemDescrpt = Item.Descrpt.
        END. 

        END.
        */
         
            @GeneratedCalculatedFieldsStart.
            FOR EACH eOrder ON ERROR UNDO, THROW:
                ASSIGN eOrder.OrderStatus = (Osprey.Util.Enum.EcommerceOrderStatEnum:GetEnum(eOrder.Stat):ToString()) .
            END.
            @GeneratedCalculatedFieldsEnd.

        END METHOD.
    Last modified on 13 May 2021 18:05 by Roger Blanchard
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    13 May 2021 in reply to Roger Blanchard
    Link to this post
    I'm not expecting the before values to change between the Begin and End trans methods regardless of the ReceiveData. 

    The before values are "fixed" from the first update and will only be reset by the accept-row-changes or reject-row-changes methods. 

    ReceiveData() is not called between the Begin and End trans methods. ReceiveData() in the Business Entity is called after the DataAccess:SaveChanges() is finished. 
  3. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    13 May 2021 in reply to Mike Fechner
    Link to this post
    That is what I thought...and what I see in all the others DataAccess classes.

    I could see the values changing in the Consultingwerk.OERA.DataAccess.cls in SaveRowChanges method right after SAVE-ROW-CHANGES.

    I commented all code in any OVERRIDE (BE and DA) and the issue went away.

    Adding OVERIDES back in one at a time I found the issue in ReceiveData.

    I removed that code and created a join to populate that description field...problem went away.

    Very odd. 
  4. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    13 May 2021 in reply to Roger Blanchard
    Link to this post
    Do debug this I'd need access to a reproducible case. 

    Do you modify tracking changes yourself anywhere in that Business Entity or Data Access class? The Business Entity should not be tracking changes when executing ReceiveData. If it does it may have strange consequences.
  5. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    13 May 2021 in reply to Mike Fechner
    Link to this post
    We do not modify tracking changes in the BE or DA.

    I have a workaround right now but will create a repro for you. Once I do I will open up a support ticket.

    Thanks
  6. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    13 May 2021 in reply to Roger Blanchard
    Link to this post
    Created repro and attached to the support ticket.

    Thanks
6 posts, 1 answered