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 Children
  • 0 in reply to Sage100User

    Thanks for the suggestion.

    I can reopen the order (which was saved on Hold, as forced by the script... even though it had a valid PreAuth with good date), try to take it off hold (which triggers the BOI script when I Accept) and the pop-up amounts are blank, even though they are on screen when the script invokes the Payments tab.  Click the Test button, and values are there.  Accept... no values in the pop-up.

    I could do an ODBC lookup if I didn't need things to work for new orders, but I know for sure the data won't be "there" (and available to ODBC) until the Write is successful... same with a new object to SO_SalesOrderPayment_bus with a lookup, the data won't be "there" for a new SO... while the SO business object should certainly have a way of accessing the Payment record for the current order.  I just need to know how to reliably access that record in a BOI script. 

    I read that PaymentObj can be accessed in a similar way to oBusObj.Lines... not a child handle, but as a property of the business object.

    If I have to invoke a button with use of oSession's SetStorageVar / GetStorageVar, I'd be very surprised.