BE FetchRelatedRecords
 

BE FetchRelatedRecords

3 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    13 Jul 2021
    Link to this post


    I am calling FetchRelatedRecords in the BE:ValidateData.

    THIS-OBJECT:FetchRelatedRecords (BUFFER ePoLine:HANDLE, "ePurchaseOrder").

    In the DataAccess class I am using Create, Modify and Delete BeginTrans to update the related record. Shouldn't this updated record make it into the DB?

    For example,

    IF AVAILABLE ePurchaseOrder THEN 
    DO: 
        TEMP-TABLE ePurchaseOrder:TRACKING-CHANGES = TRUE. 

        ASSIGN
                    ePurchaseOrder.PoAmt = ePurchaseOrder.poamt + ePoline.lineamt - ePolineBefore.lineamt + ePolineBefore.discamt - ePoline.discamt
              ePurchaseOrder.OpenAmt    = ePurchaseOrder.OpenAmt + ePoline.lineamt - ePolineBefore.lineamt + ePolineBefore.discamt - ePoline.discamt
              ePurchaseOrder.DiscAmt    = ROUND(ePurchaseOrder.poamt * ePurchaseOrder.discPerc / 100,2)
              ePurchaseOrder.Exported = FALSE /* toggle Exported field so user knows they need to send again */
              NO-ERROR.
             
              TEMP-TABLE ePurchaseOrder:TRACKING-CHANGES = FALSE. 
             
              
             
    END. 

  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    Answered
    13 Jul 2021 in reply to Roger Blanchard
    Link to this post
    It might be too late to do it in the Data Access BeginTrans methods. 

    What you're doing looks like Business Logic to me. I would code that in the Business Entity either in ValidateDate or a SaveChanges overright prior to the SUPER call.
  3. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    13 Jul 2021 in reply to Mike Fechner
    Link to this post
    Thanks Mike.
3 posts, 1 answered