Update SO field from PO button script

SOLVED

I'm trying to write a button script that will copy a single line from a SO and "pull" it into the open PO. I've done this successfully for SO (copying from Invoice or SO/Quote History), but with PO, I'd like to be able to "tie" the SO and PO together when copying the line. I can easily put the SO# into the PO line, but I'm stuck when trying to add the PO# to the SO line (since the SO isn't open and the script is running from the PO).

The following snippet results in an "Error 65: Window element does not exist or already exists"

Set oSO = oSession.AsObject(oSession.GetObject("SO_SalesOrderDetail_bus"))
retVal = oSO.SetKeyValue("SalesOrderNo$",srcOrdNum)
retVal = oSO.SetKeyValue("LineKey$",sLineNum)
retVal = oSO.Find()

retVal = oSO.SetValue("PurchaseOrderNo$",sPONum)
retVal = oSO.Write()

Is this even possible?

Top Replies