Copy link to clipboard
Copied
I am attempting to set up a script to run that will automatically complete different types of forms with demographic information- so not all forms that will use the script will be the same. I don't need this to be perfect but would like for when a field says either Zip or Zip Code, either would fill with the correct number because the word Zip appears. I'm using a custom script below that works if the field requested is Zip Code:
var zipcodefield = this.getField("Zip Code");
zipcodefield.value = "60690";
I am not sure if there is an if condition for that, and if so, I'm not sure how exactly to set it up. Can anyone help?
Sounds like this should be a folder level automation script that is run from a tool button.
https://www.pdfscripting.com/public/Automating-Acrobat.cfm
One way to do this is to search all the fields for ones that match a pattern
Here is a brute force approach:
var strFldName;
for(var i=0;i<this.numFields;i++){
strFldName = this.getNthFieldName(i);
if(/Zip/i.test(strFldName))
this.getField(strFldName).value = "9999999";
else if(/State/i.test(strFldName))
this.getFie
...
Copy link to clipboard
Copied
So if another field's value is "Zip" or "Zip Code" then you want to fill this field with that number? Should the user be able to override this value and change it to something else?
Copy link to clipboard
Copied
for what I need this, not likely. Ideally it would fill with 60690 for any form that calls for a Zip or Zip Code. Will also be using to fill fields that say "state/province" for example - I want anything that asks for a State to be Illinois
Copy link to clipboard
Copied
Sounds like this should be a folder level automation script that is run from a tool button.
https://www.pdfscripting.com/public/Automating-Acrobat.cfm
One way to do this is to search all the fields for ones that match a pattern
Here is a brute force approach:
var strFldName;
for(var i=0;i<this.numFields;i++){
strFldName = this.getNthFieldName(i);
if(/Zip/i.test(strFldName))
this.getField(strFldName).value = "9999999";
else if(/State/i.test(strFldName))
this.getField(strFldName).value = "Illinois";
}
The regular expressions and the "if" statements can be modified to include more and different conditions.
Copy link to clipboard
Copied
This is it! Much appreciated and hopefully saving our teams a lot of time. Thank you!!