Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Verification (app.alert) for read only and submit or nevermind

New Here ,
Apr 18, 2016 Apr 18, 2016

Hi javascripting ninjas. I have a MouseUp action on a button titled "Finalize&Email." Based on end user input, it is necessary to add an alert message to curtail a large volume of phone calls "I can't add information into the form anymore."

My intent was to have a button that would make the form "read only" and then submit by attaching the form to an email. But, it now seems that I need an app.alert to go along with it. So, I have been struggling on where to add the "else" statement in the JS below. Without that else statement what I get is - an email attachment with a read only form or an email that is not. What I want is - if the end user chooses "no" the user returns to the form to continue adding information. I am certain this is an easy fix, but I've gone down too many wrong rabbit holes today. Thank you in advance.

var r = app.alert("Are you sure you want to finalize and submit this document? This action cannot be undone.",2,2);

if (r == 4) { // 4 is Yes, 3 is No

for (var i = 0; i < this.numFields; i++) {

var fname = this.getNthFieldName(i);

this.getField(fname).readonly = true; // makes all fields readonly

}

}

// This is the form return email. It's hardcoded

// so that the form is always returned to the same address.

// Change address on your form to match the code below

var cToAddr = "CEQA@wildlife.ca.gov"

var cCCAddr = this.getField("PROJECT APPLICANT EMAIL").value + ";" + this.getField("LEAD AGENCY EMAIL").value;

var mySubject=this.getField("Agency").value+"|"+ this.getField("Today").value+"|"+  this.getField("Counter").value+"|"+ this.getField ("Project Title").value;

// Set the body text for the email message

var cBody = "Thank you for submitting your Document.\n\n" + "Save  the filled form attachment for your records\n\n" + "Your document is  now in good hands"

// Send the entire PDF as a file attachment on an email

this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: mySubject, cMsg: cBody});

TOPICS
Acrobat SDK and JavaScript , Windows
408
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 19, 2016 Apr 19, 2016

All you have to do is put the entire code inside the block that starts with the if-condition, like this:

if (r == 4) {

// put code to set fields as read-only and to submit the file here

}

Translate
Community Expert ,
Apr 19, 2016 Apr 19, 2016

All you have to do is put the entire code inside the block that starts with the if-condition, like this:

if (r == 4) {

// put code to set fields as read-only and to submit the file here

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 19, 2016 Apr 19, 2016
LATEST

try67​ thank you so much! That did the trick. Thank you for helping me fix this, and now I can breathe...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines