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

  • 0

    Here is an example of using the Child handle when getting a UDF value in purchase order.

    retVal=0
    itmCode=""
    oItmSvc=0
    Notes=""
    Desc=""

    retVal=oBusObj.GetValue("ItemCode$",itmCode)
    retVal=oBusObj.GetValue("ItemCodeDesc$",Desc)
    oItmSvc = oBusObj.GetChildHandle("ItemCode")
    set oItmSvc=oSession.AsObject(oItmSvc)
    retVal=oItmSvc.Find(itmCode)
    retVal=oItmSvc.GetValue("UDF_PURCHASE_ORDER_NOTES$",Notes)
    If Notes <>"" Then retVal=oBusObj.SetValue("ItemCodeDesc$",Notes)

    End Sub

  • 0 in reply to BigLouie

    Here is another one where I get the order writers name

    sFirst = "" : sLast = "" : sKey= "" : sCKey = ""

    retVal = oBusObj.GetValue("UserCreatedKey", sCKey)

    Set oUser = oBusObj.AsObject(oBusObj.GetChildHandle("UserCreatedKey"))

    retVal = oUser.getvalue("UserKey$",sKey)
    retVal = oUser.getvalue("FirstName$",sFirst)
    retVal = oUser.getvalue("LastName$",sLast)

    If sKey = sCKey then
     retVal = oBusObj.SetValue("UDF_FIRST$", sFirst)
     retVal = oBusObj.SetValue("UDF_LAST$", sLast)

    end if

  • 0 in reply to BigLouie

    With GetChildHandle the Find line shouldn't be necessary...?

  • 0

    I doubt you can access memos that way but you can check what business objects are available for GetChildHandle like this:

    oSession.AsObject(oSession.UI).MessageBox "", "" & oBusObj.GetDataSources()

  • 0 in reply to Kevin M

    "Shouldn't be" is the keyword but sometimes i find that you have to force the child object to be on the correct record and this is done either by setting each key value followed by Find or my using ReadAdditional without any arguments to force all child objects to read the "correct" record or pass the field used for the child object as the first argument to force just that child object to read the "correct" record. This should be done prior to using GetValue from the child object.

  • 0 in reply to David Speck

    Yes... "should" is not the way things always are indeed.  After your comments (here an in previous posts) I have made a mental note to try ReadAdditional the next time I have issues with a child handle.

  • 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

    For the memo info, you are likely either going to have to query the memo info through ODBC within your script or get a handle to SO_SalesOrderMemo_Bus and either set each key value, set a browse filter, or use GetResultSets to get the data you want as sales order entey does not create a child object for the memo table like it does for the customer number and salesperson number.

  • 0 in reply to David Speck

    Exactly.  If there is no child handle you have to create a new object (and find the data) or use ODBC (build your connection string with company code, authentication... set up SQL permissions when dealing with Premium... query then handle your result set).

  • 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