Renaming or Replacing a Field name through Action Wizard Jscript (batch process) Acrobat XI Pro

New Here ,
Dec 06, 2017

Copy link to clipboard

Copied

I have a signature field on a form with the name "Signature of Employer or Authorized Person".

For some reason, nothing happens when I run the script like this:

var f = this.getField("Signature of Employer or Authorized Person);

I think it's due to the spaces in between the field name. I can't change the field name through Form Edit mode since I do not own the form.

Is there a way to have this field name changed or replaced with a simpler name like "signature1" via JavaScript?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

483

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

Renaming or Replacing a Field name through Action Wizard Jscript (batch process) Acrobat XI Pro

New Here ,
Dec 06, 2017

Copy link to clipboard

Copied

I have a signature field on a form with the name "Signature of Employer or Authorized Person".

For some reason, nothing happens when I run the script like this:

var f = this.getField("Signature of Employer or Authorized Person);

I think it's due to the spaces in between the field name. I can't change the field name through Form Edit mode since I do not own the form.

Is there a way to have this field name changed or replaced with a simpler name like "signature1" via JavaScript?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

484

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
Dec 06, 2017 0
Adobe Community Professional ,
Dec 06, 2017

Copy link to clipboard

Copied

You are missing the close quote in your code.

var f = this.getField("Signature of Employer or Authorized Person");

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...
Dec 06, 2017 0
New Here ,
Dec 06, 2017

Copy link to clipboard

Copied

I missed that while posting the question here ... wasn't copying from the code ...

Have it exactly like this in my code:

var f = this.getField("Signature of Employer or Authorized Person");

Still doesn't work.

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...
Dec 06, 2017 0
Most Valuable Participant ,
Dec 06, 2017

Copy link to clipboard

Copied

JS can't rename a field. What you can do, though, is delete the old field and then create a new one in its place, with the 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...
Dec 06, 2017 0
New Here ,
Dec 06, 2017

Copy link to clipboard

Copied

Is there any guide/example to do this?

Sorry, I am not very good with JavaScript.

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...
Dec 06, 2017 0
Most Valuable Participant ,
Dec 06, 2017

Copy link to clipboard

Copied

This is not a simple task if you don't have any experience with Acrobat JS.

The full documentation is available here: Adobe - Acrobat Developer Center | Adobe Developer Connection

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...
Dec 06, 2017 0
Most Valuable Participant ,
Dec 06, 2017

Copy link to clipboard

Copied

I think you're barking up the wrong tree. If you use the correct field name, it finds the field, whether or not it has spaces. Be sure it is included exactly. Also, of course

var f = this.getField("Signature of Employer or Authorized Person");

is expected to do exactly nothing by itself,so what is next?

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...
Dec 06, 2017 0
New Here ,
Dec 06, 2017

Copy link to clipboard

Copied

So this is the whole JScript :

/* Sign all files */

trustedSigning = app.trustedFunction (

   function () {    

      var myPlatform = app.platform;

      var ppklite = security.getHandler("Adobe.PPKLite");

     

      var f = this.getField("Signature of Employer or Authorized Person");

      var digIDPath = "/C/Files/A.pfx";

      var myPsswd = "my password";

      var myLoc = " my location";

      var myReason = "my reason";

      var myContact = "my e-mail";

      var myAppearance = "Pen Sig";

     

      var oParams = {

         cPassword: myPsswd,

         cDIPath: digIDPath

      };

ppklite.login(oParams);

      app.beginPriv();

      try {

f.signatureSign( ppklite,

            {  password: myPsswd,

               location: myLoc,

               reason: myReason,

contactInfo: myContact,

appearance: myAppearance

            }

         );

      } catch (e) {

console.println("\nFatal Error = "+e.message)

      }   

      app.endPriv();

   }

)

trustedSigning();

The full steps to the batch sign process are here: How to use digital signature to sign 2000 pdfs in a folder at once.

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...
Dec 06, 2017 0
Most Valuable Participant ,
Dec 06, 2017

Copy link to clipboard

Copied

Have you checked the console for messages? That's where the scripts only messages and any reports will go.

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...
Dec 06, 2017 0
New Here ,
Dec 06, 2017

Copy link to clipboard

Copied

Yes, this is on the console on JavaScript Debugger:

12-6-2017 12-56-25 PM.png

f is null.

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...
Dec 06, 2017 0
Most Valuable Participant ,
Dec 06, 2017

Copy link to clipboard

Copied

That means you're specifying an incorrect field 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...
Dec 06, 2017 0
Adobe Community Professional ,
Dec 06, 2017

Copy link to clipboard

Copied

One can check to see if "getField" method is successful by checking to see if the variable assigned to hold the field object is "null". Note both spelling and capitalization is important. Any error in the value of the name field will result in an error.

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...
Dec 06, 2017 0
New Here ,
Dec 06, 2017

Copy link to clipboard

Copied

I picked the Field Name from the Digital Signature properties:

12-6-2017 1-53-51 PM.png

I changed the Field Name in one of the pdf files to "Signature1" and ran the script like this:

var f = this.getField("Signature1");

It worked fine then. The sign appeared on the Digital Signature field.

That's why I thought spaces between field name "Signature of Employer or Authorized Person" might be the issue here.

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...
Dec 06, 2017 0
Adobe Community Professional ,
Dec 06, 2017

Copy link to clipboard

Copied

It's possible, though unlikely, that the name contains non-printing characters other than spaces in the name. I've had that problem before with PDF created outside of Acrobat.

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...
Dec 06, 2017 0
New Here ,
Dec 06, 2017

Copy link to clipboard

Copied

This PDF was created in Adobe LiveCycle Designer 11.0

Doc properties.png

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...
Dec 06, 2017 0
try67 LATEST
Most Valuable Participant ,
Dec 07, 2017

Copy link to clipboard

Copied

In that case it's unlikely your code will work at all. LCD forms have a completely different scripting model than Acrobat forms.

Try asking here: LiveCycle Designer

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...
Dec 07, 2017 1