Java Script for Automating PDF

Recently I was tasked with creating a form or log that would track system changes. Ok no problem, until it came time to auto number the forms. I created a numbering schema, but how did I automate the numbering so that I was not bogged down with numbering each form?

My RCM Change Log # was to be made up of the Date, Site, CMMS, and Sequence Number fields

Java Script was the answer.

I scoured the internet looking for a way to automate this form and take the task of self numbering out of my hands and thought all hope was lost until I found several different help requests that were similar to my help need. So after a lot of testing I was finally able to come up with this series of java script on my form that automated the numbering of my Adobe Acrobat form.


VERB–link (things) together in a chain or series

I was able to using the Concatenate formula link together the form fields to create a function that gave me the beginning of the RCM Change Log Number.

So using the concatenate function and the “GET” formula, I strung together the Date, Site, CMMS to make the RCM Change Log Entry. That data is based on the information filled out when the form is submitted.

The Get Formula used was:

// Get the field values, as strings

var s1 = getField(“Date”).valueAsString;

var s2 = getField(“PMSite”).valueAsString;

var s3 = getField (“CMMS”).valueAsString;

// Combine values, separated by a hyphen

event.value = s1 + “-” + s2 + “-” + s3;


The Sequence Field was also a Java Script Formula using a this.field Formula, that adds +1 increment to the number each time the form is opened. To ensure we don’t have duplicate numbers on the forms.

var f = this.getField(“Sequence”);

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

f.defaultValue = f.value;

Next we added a Java Script to the Mailto Function of the Submit to Button by adding all fields together to make the subject line the complete RCM Change Log Number plus the Sequence.

this.mailDoc({cTo: “”, cSubject:this.getField(“RCM Change Log”).valueAsString + “.” + this.getField(“Sequence”).valueAsString});


So now we have an automated numbered email subject that matches the forms attached to which we can catalog on our spreadsheet to track our changes and associated forms.


Have you found any Java Script formulas that have helped you in your work?

Do you have any needs for customized forms?

Lets design something together.

[wpforms id=”1807″]


Please follow and like us:

Leave me a comment