Highlighted

How to create sequential number field?

New Here ,
Nov 17, 2013

Copy link to clipboard

Copied

I have created a pdf file and I'd like to have a field with sequential numbers.

For instance, if I open my pdf now and it has number 1 in the field, 'd like to have number 2 in the field the next time that I open the file, and so on...

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Go to Tools - JavaScript - Document JavaScripts and create a new script with the following code (remove any default code that's inside the window when you first open it):

var f = this.getField("Serial Number");

f.value = Number(f.value)+1;

f.defaultValue = f.value;

Of course, you'll might need to adjust the field name in the first line of code.

Topics

Windows

Views

24.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to create sequential number field?

New Here ,
Nov 17, 2013

Copy link to clipboard

Copied

I have created a pdf file and I'd like to have a field with sequential numbers.

For instance, if I open my pdf now and it has number 1 in the field, 'd like to have number 2 in the field the next time that I open the file, and so on...

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Go to Tools - JavaScript - Document JavaScripts and create a new script with the following code (remove any default code that's inside the window when you first open it):

var f = this.getField("Serial Number");

f.value = Number(f.value)+1;

f.defaultValue = f.value;

Of course, you'll might need to adjust the field name in the first line of code.

Topics

Windows

Views

24.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Nov 18, 2013

Copy link to clipboard

Copied

Go to Tools - JavaScript - Document JavaScripts and create a new script with the following code (remove any default code that's inside the window when you first open it):

var f = this.getField("Serial Number");

f.value = Number(f.value)+1;

f.defaultValue = f.value;

Of course, you'll might need to adjust the field name in the first line of code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Nov 18, 2013

Copy link to clipboard

Copied

Thank you so much. It worked.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Apr 02, 2014

Copy link to clipboard

Copied

This solution works great if you save the form each time after the new number count is generated.

Is there a way to have a form do a +1 each time it is opened without having to save the form?

I want to be able to give a customer a bill of lading and each time they open the blank form it generates a new auto BOL number that is +1 from the last time they opened it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Apr 02, 2014

Copy link to clipboard

Copied

How do you want the serial number field to act if the form has been assigned a serial number?

There are a lot of issues that need to be worked out for this to work well.

If the customer has it on his/her own machine how do you control the numbers across all your customers?

Will the form always be open on a machine that is always connected to the internet?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Apr 02, 2014

Copy link to clipboard

Copied

It will be a unique identifier number for that document whether printed, saved or emailed.

It is a pdf form with submit buttons, so the form information can be submitted via email as well as saved to the users computer if they wish.

If the number happens to reset with a new user on a different computer that is fine. I have decided that each user will have another field to enter their initials or a number unique only to them that will prevent confusion on duplicate numbers. For example: AB4583 (hard coded #)-______ (unique number propagates here) - _____ (User enters their initials or # here)

The primary goals is for each individual user to be able to reopen the same blank form and not see the same number twice.

I read about global objects but the document was a little more advanced than my skill level and I was not sure how to proceed with that set up. It was also a fairly old article.

Thank you

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jul 06, 2016

Copy link to clipboard

Copied

The script works great when opening the file. I am looking for a way to do a +1 every time the document is printed. Is there a way to do that?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jul 06, 2016

Copy link to clipboard

Copied

Move the code to the document's Will Print event, which you can find under Tools - JavaScript - Set Document Actions.

Edit: If you want the number to change after the file is printed use the Did Print event in the same location...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
May 27, 2017

Copy link to clipboard

Copied

Hello,

I'm trying to collect data about surgery results at 1 week, 1 month, 6 months.... is it possible to recover an autunumbered form so I can continue filling more fields?

for example. patient 1 - form assign 1 in id field, then I collect data of first week, but the form is already prepared for 1 month, 6 months, etc... Can I recover later the form number 1 so I con continue filling the rest of the form?

Thanks in advance

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
May 27, 2017

Copy link to clipboard

Copied

That choice is entirely with the form designer, you need to discuss your needs with them.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
May 27, 2017

Copy link to clipboard

Copied

I would add some code to test if the "defaultValue" is empty and then add the serial number and if it is not empty then do not update the number. Your source document will have to be saved with the "defaultValue" of the field cleared.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Nov 29, 2017

Copy link to clipboard

Copied

I am trying to do something similar, but more difficult. I need to print a 4 page PDF, it has a number field with a 3 digit number in the corner of the first page. I need the number to increase every time it prints, however, I print many copies at once, sometimes 50 to 100. Is there a way to set it to print that many copies and increase that number after each copy? Ive been trying to figure this out for about a year now, if anyone could help, please let me know.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 29, 2017

Copy link to clipboard

Copied

If you tell the printer to print X copies, then it handles the printing, outside of Acrobat. The only way to modify a value on the PDF is to control the printing yourself. A script would do this easily from a Folder level script, Command Script, or the Console window.

Contact me if you'd like such a script written.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Nov 29, 2017

Copy link to clipboard

Copied

Well that would solve all my problems if I knew how to print outside of acrobat. Im using a Mac and Ive never printed a document outside of its program. My only other issue is being able to set print settings. Its not just a plain paper document, its an exam. Its printed on 11 x 17 cardstock then folded by the printer, so I would need to incorporate those print settings as well. Not sure if its doable, but I will keep trying to find a solution to this problem. I appreciate the response.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 29, 2017

Copy link to clipboard

Copied

I think you misunderstood me.  After you press the print button, Acrobat sends the print job off to the printer. This is what I meant by outside Acrobat.  You always print outside Acrobat, because Acrobat is not a print driver.

Now what you want to do is write an Automation script in Acrobat that prints one copy at a time, changing the increment number each time.

Contact me if you want consulting/development on this issue, or post this question to a new thread if you want more free help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Aug 15, 2019

Copy link to clipboard

Copied

Very usefull for me - thanks!

How can I modify script to do NOTHING, when field "Serial Number" is empty?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Aug 15, 2019

Copy link to clipboard

Copied

Change it to this:

var f = this.getField("Serial Number");

if (f.valueAsString!="") {

    f.value = Number(f.value)+1;

    f.defaultValue = f.value;

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Aug 21, 2019

Copy link to clipboard

Copied

Thanks for Your reply, I used very similar code (from my friend):

var f = this.getField("Serial-Number");

if (f.value != "" && f.value != null) {

    f.value = Number(f.value)+1;

    f.defaultValue = f.value;

}

Works fine.

By the way, how can I tag code as “code“ :-), like You in Your last post?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Aug 21, 2019

Copy link to clipboard

Copied

I do it via the "Advanced Editor", but it's possible you won't have access to it...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 16, 2020

Copy link to clipboard

Copied

I can get the sequential numbering to work if I keep using the last form that was saved.

The master form does not update. 
Is there a way for the master form to update each time you open it?

I'm opening master form/adding my data/then save as with new file name/close tab/open original master form and number is the same.

Need a little help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jul 17, 2020

Copy link to clipboard

Copied

Save it over the "master form", then, not under a new name...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 17, 2020

Copy link to clipboard

Copied

I was able to get it to work that way, but that seems counter intuitive. I don't want to have to rename the file after everytime.

There's gotta be another way?

I've seen these global object scripts, that apparently works when using just your own computer, but haven't had any success, although, I'm probably doing it wrong. 

I tried to add a required one time click button to add +1 to current number, but not sure how to create a "one time" click funcion.

The only thing that I was able to make work is use the date and time to create a unique number, but then it's not really sequential. 

I'm hoping to make the sequential number work somehow. 
I'll keep trying. 

 

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 17, 2020

Copy link to clipboard

Copied

Forgot to mention that I'm also trying to find a way to save the file as per one of the fields I'm using. Want it to save as per the customer name. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Resources
One Stop Solution for Acrobat
Edit a PDF