1 person found this helpful
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.
Thank you so much. It worked.
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.
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?
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.
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?
1 person found this helpful
Edit: If you want the number to change after the file is printed use the Did Print event in the same location...
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
That choice is entirely with the form designer, you need to discuss your needs with them.
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.