Script in AR_CashReceiptDetail - Set InvoiceNumber

Hi Experts,

I wrote a script that will allow a user to enter a secondary ID number (not the Sage InvoiceNumber) in the InvoiceNo field in CashReceipts Entry detail. The user enters the secondary ID, my script grabs the number, looks up the correct Sage InvoiceNo and then is supposed to write this number back into the InvoiceNo field. The write-back part is my issue. I return the correct number, but Sage asks me if it is a Prepayment. If I click okay, it creates the correct InvoiceNo + "-PP". If I manually enter the same InvoiceNo into the next line, it finds the invoice and correctly sets it as -"IN"

I tried running the script on the Pre- and PostValidate Events for the InvoiceNo field in AR_CashReceiptDetail. Both don't work. What am I missing? It looks like Sage doesn't look up the Invoice Information when I stuff it through SetValue. Please see the relevant part of the script below.

If sSageInvNo <> "" Then

retVal = oScript.DeactivateProcedure("PreValidation_InvoiceNo")

retVal = oBusObj.SetValue("InvoiceNo$", sSageInvNo)

retVal = oScript.ActivateProcedure("PreValidation_InvoiceNo")

End If

Thanks for your help!

Best,


B.