These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Changing Serial/Invoicel Number field

pdfer
Registered: Dec 23 2010
Posts: 28
Answered

Does any one know how to create a field that would contain a number? Then everytime the doc is opened the Serial/Invoice Number field would advance by, let's say, 1.
 
And,
 
The other thing I'd like to create is a drop down box containing all the US states. Would anyone have these two scripts? Let me know, k. Thanks folks.

Jackson C.

My Product Information:
Acrobat Pro 9.0, Macintosh
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
JavaScript may have the answers, but not a simple one liner.


Incrementing a number:
You solution will depend upon how your form will be processed. You can use the global object and the subscribed method. Otherwise you need to link to a database and use ADBC.

The states drop down can be populated by JS. The following document level JS will populate a field called 'States'.

// function to load combo box or list box
function SetStates(sFieldName) {

//define an array of state name and abbreviation array
var aStateAbrev = new Array([' ', ' '],
['ALABAMA','AL'],
['ALASKA','AK'], ['AMERICAN SAMOA','AS'],
['ARIZONA', 'AZ'], ['ARKANSAS', 'AR'],
['CALIFORNIA', 'CA'], ['COLORADO', 'CO'],
['CONNECTICUT', 'CT'], ['DELAWARE', 'DE'],
['DISTRICT OF COLUMBIA', 'DC'],
['FEDERATED STATES OF MICRONESIA', 'FM'],
['FLORIDA', 'FL'], ['GEORGIA', 'GA'],
['GUAM', 'GU'], ['HAWAII', 'HI'],
['IDAHO', 'ID'], ['ILLINOIS', 'IL'],
['INDIANA', 'IN'], ['IOWA', 'IA'],
['KANSAS', 'KS'], ['KENTUCKY', 'KY'],
['LOUISIANA', 'LA'], ['MAINE', 'ME'],
['MARSHALL ISLANDS', 'MH'], ['MARYLAND', 'MD'],
['MASSACHUSETTS', 'MA'], ['MICHIGAN', 'MI'],
['MINNESOTA', 'MN'], ['MISSISSIPPI', 'MS'],
['MISSOURI', 'MO'], ['MONTANA', 'MT'],
['NEBRASKA', 'NE'], ['NEVADA', 'NV'],
['NEW HAMPSHIRE', 'NH'], ['NEW JERSEY', 'NJ'],
['NEW MEXICO', 'NM'], ['NEW YORK', ', NY'],
['NORTH CAROLINA', 'NC'], ['NORTH DAKOTA', 'ND'],
['NORTHERN MARIANA ISLANDS', 'MP'], ['OHIO', 'OH'],
['OKLAHOMA', 'OK'], ['OREGON', 'OR'],
['PALAU', 'PW'], ['PENNSYLVANIA', 'PA'],
['PUERTO RICO', 'PR'], ['RHODE ISLAND', 'RI'],
['SOUTH CAROLINA', 'SC'], ['SOUTH DAKOTA', 'SD'],
['TENNESSEE', 'TN'], ['TEXAS', 'TX'],
['UTAH', 'UT'], ['VERMONT', 'VT'],
['VIRGIN ISLANDS', 'VI'], ['VIRGINIA', 'VA'],
['WASHINGTON', 'WA'], ['WEST VIRGINIA', 'WV'],
['WISCONSIN', 'WI'], ['WYOMING', 'WY'],
['Armed Forces Africa, Canada, Europe, & Middle East', 'AE'],
['Armed Forces Americas', 'AA'],
['Armed Forces Pacific', 'AP']
) // end of array

//Insert array of states andabbreviations into the combobox
this.getField(sFieldName).setItems(aStateAbrev);
return true;
} // end SetStates function

// call the function for field named "States"
SetStates("States");



George Kaiser

pdfer
Registered: Dec 23 2010
Posts: 28
The States combo worked very well. And, thank you for your help. But, I have another question. How do I set a Default such as CA? What I've done to achieve this - was to go into the field's Properties and entered in CA as the item and CA as the value, then deleted the CA populated by the script. It works but I'm sure it's not the right way. What do you think?

Jackson C.

DaveyB
Registered: Dec 10 2010
Posts: 70
For the States field, in Livecycle, go to the custom fields tab, and select the "U.S. States" object, which comes pre-populated with all of the States. Once in place, set the onject - value - default to "CA" and you're done :)

As George pointed out, in order to increment a number from one form to the next would require an external data source, along with the logic to check whether the previous number was actually used or if someone just opened the form by mistake (in which case the number was not used and should still be available)

DaveyB

LiveCycle Designer 8.0
"Genius is one percent inspiration, ninety-nine percent perspiration." ~~ Thomas Edison
"If at first you don't succeed, get a bigger hammer." ~~ Alan Lewis
"If the conventional doesn't work, try the unconventional" ~~ DaveyB

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Unfortunately, Acrobat for Macintosh does not include the LiveCycle Designer program.

For the serial number look at Acumen Journal for August of 2004. Because of security changes starting with version 8, you will need to use additional coding as explained in the Acrobat JS API Reference.The default item is the one selected when saved. Once populated you can move the items up or down as desired, as long as the 'sort items' option is not checked. Also once you have the combo box populated as one form field in a PDF, you can save the PDF, close the PDF,and them add that PDF as a page to another PDF and bring the combo box into a new form.

George Kaiser

DaveyB
Registered: Dec 10 2010
Posts: 70
gkaiseril wrote:
Unfortunately, Acrobat for Macintosh does not include the LiveCycle Designer program.
Seems Adobe have some urgent fixing to do :)

LiveCycle Designer 8.0
"Genius is one percent inspiration, ninety-nine percent perspiration." ~~ Thomas Edison
"If at first you don't succeed, get a bigger hammer." ~~ Alan Lewis
"If the conventional doesn't work, try the unconventional" ~~ DaveyB

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
It started with JetForm, so there maybe there are issues outside of Adobe's control.We just need to keep track of version specific features and adjust for them.

George Kaiser

maxwyss
Registered: Jul 25 2006
Posts: 255
gkaiseril wrote:
Unfortunately, Acrobat for Macintosh does not include the LiveCycle Designer program.
Unfortunately???

Fortunately!

grin, duck and run

maxwyss
Registered: Jul 25 2006
Posts: 255
About the serial number, it really depends on how the form is used, and how important the uniqueness and sequence order of your serial number is.

If only uniqueness is important to you, you could have Acrobat/Reader autocreate a serial number, based on the current date and time (assuming that it is extremely unlikely that two users initiate the serial number creation within the same millisecond). If a continuous sequence is important, you will not get around a centralized solution, where a server process manages the serial numbers.

ODBC has been mentioned, but one must be aware that ODBC/ADBC has been scrapped from Acrobat with Acrobat 10. The method to directly connect to a local database would be SOAP (until that gets scrapped too...). Otherwise, you would do a real online solution where you send a request to a server which returns the serial number (via FDF or XFDF). This does, however, require some infrastructure.

HTH.

Max Wyss.