Skip to main content
Participant
August 15, 2016
Answered

Folder Level Javascript will run from Menu Item but not from Button - Need Work Around...Please help

  • August 15, 2016
  • 3 replies
  • 816 views

I have a JavaScript type script that contains a trusted function with a SOAP transaction inside of the trusted function. 

This function is inside of a folder level script. 

When I call this function from a menu item, it works great.

When I try to add and call this function from a button or from a Signature Field under the execute JavaScript when signed, it will not work and I get an error message.

What am I missing and Is there a work around, I need to run from a button or from a Signed field?

Any Ideas?

This topic has been closed for replies.
Correct answer perryb23898463

//  How to Run Privileged Javascript from a button

//    1.  Need to place the needed Javascript inside of a function in the Javascripts folder

//    2.  The Javascript must be a Trusted Function

//    3.  Add the call to the trusted function to the button

//

//  The Button Code for Run a Javascript on Mouse Focus is ->  Trusted_CustomCode();

//

//  The example below is a Folder Level JavaScript for Security Reasons

//

//  The example code MUST BE encapsulated in a Trusted function which is part of <custom_filename>.js in javascripts folder

//

var Trusted_CustomCode = app.trustedFunction(CustomCode);

function CustomCode() {

   app.beginPriv();

          

        //Custom JavaScript Code Goes Here

                  app.alert("This is my Custom Code that will run from a button");

        // End of Custom Javascript Code

  app.endPriv();

}

3 replies

perryb23898463AuthorCorrect answer
Participant
August 15, 2016

//  How to Run Privileged Javascript from a button

//    1.  Need to place the needed Javascript inside of a function in the Javascripts folder

//    2.  The Javascript must be a Trusted Function

//    3.  Add the call to the trusted function to the button

//

//  The Button Code for Run a Javascript on Mouse Focus is ->  Trusted_CustomCode();

//

//  The example below is a Folder Level JavaScript for Security Reasons

//

//  The example code MUST BE encapsulated in a Trusted function which is part of <custom_filename>.js in javascripts folder

//

var Trusted_CustomCode = app.trustedFunction(CustomCode);

function CustomCode() {

   app.beginPriv();

          

        //Custom JavaScript Code Goes Here

                  app.alert("This is my Custom Code that will run from a button");

        // End of Custom Javascript Code

  app.endPriv();

}

Legend
August 16, 2016

Glad you have it working. If you have time, can you let us know what you were doing wrong? For future reference, in cases like this, you should post the code you are using (or a radically simplified test case) and most especially the exact error message.  Because... what you've posted is exactly what I'd expect you to have seen in the first case.

Participant
August 15, 2016

Thank you - but your reply is not on target.

I am trying to execute a JavaScript to update a database field to show that the document has been signed.

Inspiring
August 15, 2016

ADBC, Adobe Data Base Connection, was fully removed from Acrobat in version X.

Or if you are trying to update a field after the PDF has been signed you will invalidate the signature since the digital certificate by design is to indicate if any bit of any byte in the PDF has been changed. Also you may have locked all the fields by applying the digital certificate.

Inspiring
August 15, 2016

Not all menu items are available to Acrobat/Reader JavaScript for many reasons. For signatures it is a security issue and international standard that the person applying the signature can be verified each time the signature certificate is applied. This means the person applying the signature must enter his/her unique password each time the certificate is applied. Now if the user wants to share his/her password with another, then he/she must be willing to deal with the legal ramifications. Think about signing a multi-million dollar contract.