JavaScript - Set file number counter everytime a file is opened and save with that.
Hello,
I am in the process of creating a contract template for our company. We would like to be able to send this document out to our customers for them to sign. I would like to assign a different contract number to each document that I resave (save as) under a customer's name. Everytime I do this I would like to have the contract start with a new distinct contract number. I will be working off of the master template (file). I would like the number to start with 100001. Currently, I am using this JavaScript but it is only putting one digit at a time. I started with a 1, then number 2, now I am at number 3. Only one single digit. My field is titled Agreement Number. Can you please help me with a solution?
var f = this.getField("Agreement Number");
if (f.value=="") f.value = "100001";
else f.value = util.printf("%04d", (Number(f.value)+1));
