Read a Sales Order Detail record from a script.

Sage v4.5 with JobOps

I want to default a value from the Parent Item in Sales Order.

I have the key to the Sales Order Detail and I am not getting an error, but I am not getting a value for Item Number or Quantity.

This is my script.    Thank you in advance.

cHdr=""
cHdrLin=""
cQty=0
cItem=""
retVal = oBusObj.GetValue("SalesOrderNo$",cHdr)
retVal = oBusObj.GetValue("HdrParentLineKey$",cHdrLin)
Msgbox(cHdr)
MsgBox(cHdrLin)
set oParent = oSession.AsObject(oSession.GetObject("SO_SalesOrder_bus"))
retval = oParent.SetKeyValue("SalesOrderNo$", cHdr)
retval = oParent.SetKeyValue("LineKey$", cHdrLin)
retval = oParent.Find()
retVal = oParent.GetValue("QuantityOrdered",cQty)
retVal = oParent.GetValue("ItemCode$",cItem)