Good day everyone..
I have a BO called: Document No.
In this Document No attribute are: Type, Prefix, Number, Suffix, Next Document No
Type...............Prefix........Number........Suffix....Next Document No
Sales Invoice...SI-...........1000.............-2011......SI-1000-2011
When user create the new invoice and the document no is undefined, I will automatic use the Next Document No for the sales invoice, and the Number will add 1 (ie. become 1001)... and so on...it worked. But I have a problem how to track duplicate invoice.
Assume now the Next Document No is SI-1002-2011. But the user enter the sales invoice document by himself, say SI-1002-2011, so the document no is defined, it will not pick up the from the document no BO.
Next invoice, my document no Bo show next document no is SI-1002-2011, so before I update the Sales Invoice Document No, I need the system to check whether any sales invoice with this same document no.
Find DocumentNo Where Type='Sales Invoice'
EXISTS SalesInvoiceHeader WHERE (SalesInvoiceHeader.DocumentNo=DocumentNo.NextDocumentNo)
If found: then DocumentNo.Number =DocumentNo.Number+1
At this stage. the Next Docment No is SI-1003-2011. But at this point, how to check again whether SI-1003-2011 is exist in the Sales Invoice before update the Sales Invoice Document No. The next document no SI-1003-2011 could be use again..
I need the system to check until the next document no is not used before update the sales invoice number.
Any tips how to do it? Million thanks.