Then maybe you can give draft documents a temporary name like temp-inv-0001 then create a server script on submit to Rename Doc
In that case,
- There is no need for our additional fields
- Set the default naming series to “Temp-INV-####”
- Create a server script on submit that will;
3.a. Get last doc from invoiceIndex
3.b. Get the last_doc.index
3.c. Check customer territory if it’s export or not
3.d. Rename the current doc to “INV-last_doc.index” or “INV-EX-last_doc.index”
3.e. Delete all docs in invoiceIndex
3.f. Create a new doc in invoiceIndex with the index oflast_doc.index + 1