Sunny wrote:Hi Mike,
We have written a subroutine to prefix the default sales order no. created by JIWA, and write it back to the database. This is in the SaveEnd routine, so there are no changes post this. We need to refresh the form so that the user can see the new Sales Order No.
Thanks.
Sunny
I'd like to add that there is perhaps a better way to do what you want, other than programmatically clicking the refresh button - which I might add results in a double read of the order on save, and has an integrity risk.
If you want to customise the sales order number to be something other than the auto-generated one, you can hook into the SaveStart event and set the InvoiceNo property there. We won't try to set the InvoiceNo property using the built-in sequence numbering system on new orders if it is not blank. That way you don't need to cause a second subsequent read (by programmatically clicking the refresh button). When the save finishes, the form will correctly display the invoice number. It also means any other aspect of Jiwa or plugins examining or using the InvoiceNo field on save will have your invoice number.
Altering the InvoiceNo using a SQL update on SaveEnd, then forcing a refresh may appear to work, but anything between SaveStart and SaveEnd will be misinformed as to what the InvoiceNo really is. You also run the risk of not actually setting the invoice no. - if it is a duplicate in SO_Main, the unique index on SO_Main.InvoiceNo will cause an exception, and it will already have saved with the generated invoice no. anyway - so your user gets an exception about a unique index violation, and the order is already committed with the auto-generated invoice no.
TLDR; I think you're doing it wrong.