Skip to main content
July 19, 2017
Answered

Acrobat Pro DC Running JavaScript

  • July 19, 2017
  • 1 reply
  • 2122 views

I am running JavaScript in my Acrobat Doc to validate and flatten all the entered fields and attach the pdf file to an email. Everything works perfectly.

I added a field for signature and the button does not work then the form is signed. I am not sure if the signature disables the button or prevents JavaScript from running. I would really appreciate any help. Thank you.

Here is my code.

var success = 0;

var validEntries = false;

for (var i = 0; i < requiredFields.length; i++) {

  var fieldName = requiredFields;

  var field = this.getField(fieldName);

  if (isFilled(field.value)) {

  success ++;

  } else {

  app.alert("Please enter the selected required field.");

  field.setFocus();

  break;

  }

}

if (success == requiredFields.length) {

  for (var i = a_and_l_services.length - 1; i >= 0; i--) {

  if (this.getField(a_and_l_services).value == "On") {

  validEntries = true;

  break;

  }

  }

}

if (validEntries) {

  disable();

  var toAddr = this.getField(someField).value;

  var toCC = "email@example.com";

  var subject = this.getField(field1).value + " - " + this.getField(field2).value + " - Review Required - Architecture and Launch";

  var message = "Exception Review Required - Architecture and Launch Services. The attached file is the filled-out form. Please open it to review the data.";

  this.mailDoc({bUI: true, cTo: toAddr, cCc: toCC, cSubject: subject, cMsg: message});

}

function isFilled(str) {

  return str != "" && str != "nil" && str.length != 0;

}

function disable() {

  for (var i = allFields.length - 1; i >= 0; i--) {

  var field = this.getField(allFields);

  field.readonly = true;

  field.fillColor = ["G", 0.75];

  field.borderColor = ["G", 2/3];

  field.textColorr = ["G", 0.5];

  }

}

This topic has been closed for replies.
Correct answer try67

Normally speaking, once a file is signed it locks it and prevents further editing.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 20, 2017

Normally speaking, once a file is signed it locks it and prevents further editing.

July 20, 2017

Hi try67 , thanks for your reply. Do you suggest that I run a script when the signature field is signed to unlock the other fields or at least the button? The button seems to be completely disabled.

try67
Community Expert
Community Expert
July 20, 2017

Go to the Properties of the Signature field, and under the Signed tab you can tell it what fields to lock, if at all.