Copy link to clipboard
Copied
Hello,
I need to have my form auto-generate a number in a specific format as follows: I(or E)-23-0901-01.
-I or E: represents the document type, (Invoice or Estimate) based on a selection made in a dropdown list. (The dropdown field is named "doctype")
-23: represents the current year (yy)
-0901: represents the current month and day (mm/dd), but without the backslash)
-01: represents the order of creation 01, 02, 03......etc. (starting over at 01, 02, 03, etc., on the next day or date.
I'd like the # to generate upon opening a new document from a template and lock the number when it is saved and then emailed to my server. Only one person will be creating this document. Can this be done?? (The number field is named "NO"). Thanks in advance for any help given.
Vicki23142119gd8
Copy link to clipboard
Copied
Generating the format you've specified is not a problem. There are however issues with doing this on document open, and with setting the order number. It is possible to create these features, but they would only work in Acrobat/Reader and they would not be entirely reliable. A more robust option is to have a "Make Inoice#" button.
Copy link to clipboard
Copied
Hhhhhhmmkay! How do I do that?
Copy link to clipboard
Copied
Ok heres a button MouseUp script:
var strInvNum = "";
if(this.getField("doctype").value == "Invoice")
strInvNum = "I-";
else
strInvNum = "E-";
if(global.setDate != util.printd("yy-mmdd",new Date)){
global.setDate = util.printd("yy-mmdd",new Date);
global.OrderNum = 1;
}
else
global.OrderNum++;
strInvNum += global.setDate + "-" + util.printf("%02d",global.OrderNum);
Copy link to clipboard
Copied
Hi,
This assumes the Acrobat application is open all day long without any crashes... Otherwise you would have to use a "counter" file or a dialog box if the global variable is not defined, to know where to resume counting!
@+
Copy link to clipboard
Copied
True, but setting the globals as persistent is a reasonable solution.
Copy link to clipboard
Copied
Hi,
So, I suggest you add a dialog box for the first opening of the file after the Acrobat application launching.
Add these lines at the begining of the script:
if (isNaN(global.OrderNum)) {
global.OrderNum=app.response({
cQuestion: "Where do you want to start numbering?",
cTitle: "Numbering",
cLabel: "Number #",
cDefault: 1
});
global.OrderNum--;
global.setDate = util.printd("yy-mmdd",new Date);
}
Please have a look on tha attached example file.
@+