A customer has asked for an easy way to change the invoice date for an entire batch (without using VI). What I am trying is a button script run from SO Invoice Entry, opening a new object, grabbing the ModuleDate, scrolling through the batch and setting the invoice date one at a time. That part works, but at the end of the script I get an error 84 (crashing the UI).
Is what I am attempting feasible? Can I not open a new instance of SO_Invoice_Bus from within an SO Invoice Entry button script?
oInvoiceEntry = oSession.GetObject("SO_Invoice_Bus") Set oInvoiceEntry = oSession.AsObject(oInvoiceEntry) oInvoiceEntry.SetIndex("KBATCH") oInvoiceEntry.SetBrowseFilter(sBatchNo) retVal = oInvoiceEntry.MoveFirst() do until oInvoiceEntry.EoF sLoopInvoiceNo = "" retVal = oInvoiceEntry.GetValue("InvoiceNo$", sLoopInvoiceNo) if sLoopInvoiceNo <> sInvoiceNo then ' skip over the currently open invoice. retVal = oInvoiceEntry.SetValue("InvoiceDate$", sModuleDate) retVal = oInvoiceEntry.Write() end if retVal = oInvoiceEntry.MoveNext() loop ' oInvoiceEntry oInvoiceEntry.SetIndex("KPRIMARY") Set oInvoiceEntry = nothing
Trying to invoke Accept before the loop doesn't change anything.
retVal = oScript.InvokeButton("BT_Accept") retVal = oUIObj.HandleScriptUI()
I also tried with and without forcing close the current invoice (before the loop), with the same error. (If I do this, the SetValue on the current invoice works, and all the other invoices in the batch are updated, but it still crashes the screen... which is not something I could enable on a customer system).
retVal = oBusObj.Write() retVal = oBusObj.Clear()