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
  • 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

Reply
  • 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

Children
  • 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 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.