oSession.AsObject(oBusObj.PaymentObj) inconsistent results in SO scripts

SOLVED

I have this code in a BOI script (SO Header, PreWrite)...

...
Set oPayment = oSession.AsObject(oBusObj.PaymentObj)
retVal = oPayment.GetValue("CreditCardAuthorizationNo$", sAuthNo)
retVal = oPayment.GetValue("AuthorizationDate$", sAuthDate)
retVal = oSession.AsObject(oSession.UI).MessageBox("","CreditCardAuthorizationNo " & sAuthNo & " sAuthDate " & sAuthDate)

But it is coming up blank.

Yet I have a button script on the panel with the exact same script code, and it works?!?

Is there something I can do in a BOI script to reliably get access to the CC payment data for an SO?

I tried adding these lines, but nothing seems to help.

retVal = oBusObj.ReadAdditional("PaymentType")

retVal = oBusObj.ReadAdditional("PaymentTypeCategory")

retVal = oBusObj.ReadAdditional("PaymentObj")

(Big picture of the script is to check for a valid PreAuth on an SO for customers with certain Terms... so I need reliable access to payment data to check the Auth #, amount and date).

Parents Reply
  • +1 in reply to Kevin M
    verified answer

    Try a MoveFirst and then loop through until you hit EoF while outputting the GetKey() to either the trace window or a MessageBox (i would avoid the latter if there are more than a few records in the payment table) then you might want to follow up with a Clear to put it back in the same state you found it in.

Children
  • 0 in reply to David Speck

    Thanks David... such a loop seems to go through Payment records filtered to the current SO (not the whole table).

    Probably done that way because there could technically be multiple payment records on an SO.

    For an SO like this, it loops through the two records, which makes sense and is something I'll have to accommodate but I should be able to do that.