GetChildObject Method Works Differently in Button Script and in UI Script

SOLVED

My A/R CashReceiptsEntry button script works from the DMAIN panel and the PLINES panel, but as an OnExit script on the PLINES panel it does not work.

The symptom is that a GetChildObject method doesn't return the related record (from AR Open Invoice table). It only returns data related to the last detail line entered/modified. In other words, the AR Open Invoice table object returns the same data for both detail lines ignoring the oLines.MoveFirst and oLines.MoveNext.. IT WORKS WELL AS A BUTTON SCRIPT!!!
Simplified code below.

retVal = oLines.MoveFirst
Do While Not(CBool(oLines.EOF))
    Set oOpenInvoice = oSession.AsObject(oLines.GetChildHandle("InvoiceNo"))
    retVal = oOpenInvoice.GetValue("InvoiceNo$", sInvoiceNo)
    retVal = oScript.DebugPrint("sInvoiceNo = " & sInvoiceNo)
    retVal = oLines.MoveNext
Loop

I also tried breaking apart the oSession.AsObject from the GetChildHandle and can see that a valid looking object handle is being returned.