How to get Child or sub file (table) level data from Sage VB Script

SUGGESTED

Hi All,

  I need to display a message box on Shipping Data Entry interface.  I can get data from "SO Sales Order Header"  and "SO Shipping Data Entry" and "Customer....".

On Custom Office using trigger of ""SO Shipping Data Entry"" and Pre-Write.

But, I could NOT get MEMO data from "SO Sales Order Memo" using the same logic code.  Please help!  Thank you all.

retVal = 0
oCust = 0
memo_code = ""

SET oCust = oBusObj.AsObject(oBusObj.GetChildHandle("SalesOrderNo"))

retVal = oCust.GetValue("MemoCode$", memo_code )
retVal = oScript.SetError("MEMOCODE string - is not blank! " & memo_code )

' set oCust = oSession.AsObject(oBusObj.GetChildHandle("SalesOrderNo"))  --- tested
' Set oCust = oSession.AsObject(oBusObj.GetChildHandle(“CustomerNo”)) --- sample

Parents Reply Children
  • 0 in reply to Kevin M

    Hi Kevin,  

    Thank you so much for your reply!  I ran the code and checked the object as following objects listed below. Is there a way to get access to:  "SO_SalesOrderMemo "?  Best regards!

     Fld  Column Name                     M/L TUR  Description/Notes              Class

       1  SalesOrderNo. . . . . . . . .     7 SYY  Sales Order Number. . . . . . .SALESORDERNO
                                                    FmtType:CHARNUM Notes:
                                                    {SO1$(1,7)}
       2  MemoCode. . . . . . . . . . .    10 SYY  Memo Code . . . . . . . . . . .MEMOCODE
       3  SeqNo . . . . . . . . . . . .     6 SNN  Sequence Number . . . . . . . .
       4  MemoDesc. . . . . . . . . . .    30 SNN  Memo Description. . . . . . . .DESCRIPTION
       5  MemoDate. . . . . . . . . . .     8 SNN  Memo Date . . . . . . . . . . .DATE
       6  ExpirationDate. . . . . . . .     8 SNN  Expiration Date . . . . . . . .DATE
       7  ReminderStartDate . . . . . .     8 SNN  Reminder Start Date . . . . . .DATE
       8  ReminderEndDate . . . . . . .     8 SNN  Reminder End Date . . . . . . .DATE
       9  AutoDisplaySetting. . . . . .     1 SYN  AUTO Display Setting. . . . . .
                                                    DfltVal:N Valid:Y,N,D Notes:
                                                    Y=Always, N-Never, D=by
                                                    reminder Date
      10  Attachment. . . . . . . . . .   128 SNN  Attachment. . . . . . . . . . .
      11  MemoText. . . . . . . . . . .  7168 SNN  Memo Text . . . . . . . . . . .MEMO
      12  OriginalModuleCode. . . . . .     3 SNN  Original Module Code. . . . . .
      13  OriginalMemoType. . . . . . .     2 SNN  Original Memo Type. . . . . . .
      14  DateCreated . . . . . . . . .     8 SNN  Creation Date . . . . . . . . .DATE
                                                    Read Only:Y
      15  TimeCreated . . . . . . . . .     8 SNN  Creation Time . . . . . . . . .TIME
                                                    Read Only:Y
      16  UserCreatedKey. . . . . . . .    10 SNN  Creation User ID. . . . . . . .
                                                    Read Only:Y
      17  DateUpdated . . . . . . . . .     8 SNN  Last Update Date. . . . . . . .DATE
                                                    Read Only:Y
      18  TimeUpdated . . . . . . . . .     8 SNN  Last Update Time. . . . . . . .TIME
                                                    Read Only:Y
      19  UserUpdatedKey. . . . . . . .    10 SNN  Last Update User ID . . . . . .
                                                    Read Only:Y
    

    -----------------------------

    MAIN, 
    PaymentType
    ArDivisionNo
    CustomerNo
    TaxSchedule
    SalesOrderNo
    TermsCode
    SalesPersonDivisionNo
    SalesPersonDivisionNo2
    SalesPersonDivisionNo3
    SalesPersonDivisionNo4
    SalesPersonDivisionNo5
    SalesPersonNo
    SalesPersonNo2
    SalesPersonNo3
    SalesPersonNo4
    SalesPersonNo5
    ShipVia
    BillToCountryCode
    ShipToCountryCode
    BillToZipCode
    ShipToZipCode
    ShipToCode
    ShipperId
    BillToDivisionNo
    BillToCustomerNo
    areHouseCode

  • 0 in reply to cobbler

    I would use something like the following to get the object handle.

    nSO_SalesOrderMemo_Bus = 0 : nSO_SalesOrderMemo_Bus = oSession.GetObject("SO_SalesOrderMemo_Bus")
    If nSO_SalesOrderMemo_Bus > 0 Then
        Set oSO_SalesOrderMemo_Bus = oSession.AsObject(nSO_SalesOrderMemo_Bus)
        ' Get data here.
        Set oSO_SalesOrderMemo_Bus = Nothing
    End If

  • 0 in reply to David Speck

    I typically add an Else to that if statement, so the user receives a pop-up when permission needs to be added.

  • 0 in reply to Kevin M

    I do that as well on scripts where the user needs to know the script could not access other objects. Best to avoid doing this on a line level script unless you use a variable with SetStorageVar and GetStorageVar so you only display the warning once otherwise you are going to aggravate the end user if the script is only handling non-critical processes or for displaying non-critical info.

  • 0 in reply to David Speck

    Hi David,

    Thank you so much for your advise and example.   I test it in my code and did not get any data.  Please see below.  

    Please advise maybe I did it incorrect?   

    Best regards! 

    -------------------------

    If nSO_SalesOrderMemo_Bus > 0 Then

    '''' Get data here.
    Set oSO_SalesOrderMemo_Bus = oSession.AsObject(nSO_SalesOrderMemo_Bus)

    retVal = oSO_SalesOrderMemo_Bus.GetValue("MemoCode$", memo_code )
    retVal = oScript.SetError("MEMOCODE string - is not blank! " & memo_code )


    Set oSO_SalesOrderMemo_Bus = Nothing
    End If

    -------------------------- 

  • 0 in reply to cobbler
    SUGGESTED

    My sample code was merely to get the object handle, you will have to use the appropriate method to locate the correct memo code record based on your criteria.

    Use either one of the following options.

    • Find
    • SetKeyValue & Find
    • SetBrowseFilter & MoveFirst/MoveLast
    • GetResultSets