Skip to main content
Participant
September 4, 2023
Question

AUTO GENERATE AN INVOCIE # IN A SPECIFIC FORMAT

  • September 4, 2023
  • 1 reply
  • 1526 views

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

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
September 4, 2023

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. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
vkchavesAuthor
Participant
September 6, 2023

Hhhhhhmmkay! How do I do that?

Thom Parker
Community Expert
Community Expert
September 6, 2023

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);

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often