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

Submit Button: Check Required Fields then Send Read Only File by Email

New Here ,
Jul 25, 2019 Jul 25, 2019

Copy link to clipboard

Copied

I have a submit button on the form I'm creating.

1) After researching various examples, I have the following JS set up:

var emptyFields = [];

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

     var f= this.getField(this.getNthFieldName(i));

     if (f.type!="button" && f.required ) {

          if (f.valueAsString==f.defaultValue) emptyFields.push(f.name);

     }

}

if (emptyFields.length>0) {

     app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));

}

It seems to be working but it still allows the document to be sent by email after clicking OK on the warning window.  Any ideas on how to fix that?  Ideally, I would like the user to be returned to the form to finish completing the document.

2) Is there a way to send the form in a read only format without changing it for the user?  I'm noticing in my tests that when I have the document sent to me, I am able to change the fields.  I wouldn't want that to be the case.  Ideally, I would like the person receiving the file by email to not be able to change any of the information.  Any ideas?

In case it helps, below is the JS I've written for the submit button to email the form:

var cToAddr = "email@email.com";

var cCcAddr = this.getField("DeptEmail").value;

var cSubLine = "CRT Submission";

var cBody = "This Civil Routing Transmittal (CRT) and attached supporting documents are hereby submitted.";

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

Thanks in advance!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

475

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
community guidelines
LEGEND ,
Jul 25, 2019 Jul 25, 2019

Copy link to clipboard

Copied

A. You say item (2) is JavaScript on the submit button. But where is the JavaScript located for item (1)?

B. Will your end users each have Acrobat Pro?

Votes

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
community guidelines
New Here ,
Jul 25, 2019 Jul 25, 2019

Copy link to clipboard

Copied

I have two JS actions set up on the submit button.  First is the script to check for empty fields and second is the script to send the document.

Votes

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
community guidelines
LEGEND ,
Jul 25, 2019 Jul 25, 2019

Copy link to clipboard

Copied

A. If you have two sets of JavaScript it will always run both. You need to merge them into one, and submit only if the test fails.

B. Will your end users each have Acrobat Pro?

Votes

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
community guidelines
LEGEND ,
Jul 25, 2019 Jul 25, 2019

Copy link to clipboard

Copied

Sorry, submit only if the test SUCCEEDS!!

Please answer question B so we can answer your question more fully.

Votes

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
community guidelines
New Here ,
Jul 25, 2019 Jul 25, 2019

Copy link to clipboard

Copied

Yes, submit only if the test succeeds...how would I code that?

No, not all users will have Adobe Pro.  I'm guessing most will have Reader.

Votes

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
community guidelines
New Here ,
Jul 29, 2019 Jul 29, 2019

Copy link to clipboard

Copied

I think I've simplified my questions...

Can I disable the submit button until all fields are answered?

Can I set up the submit button to send a flattened version of the completed form?

Votes

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
community guidelines
Community Expert ,
Jul 29, 2019 Jul 29, 2019

Copy link to clipboard

Copied

- Yes, you can do that using a custom calculation script of a (hidden) text field.

- If the file is going to be used in Reader you can't actually flatten it, only set all the fields in it as read-only.

Votes

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
community guidelines
New Here ,
Jul 29, 2019 Jul 29, 2019

Copy link to clipboard

Copied

LATEST

Ok, I suppose that makes sense.  How would I go about doing either of those?  I apologize, I'm not skilled at JavaScript...just able to piece things together from your help and other examples from the forums.  Thanks.

Votes

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
community guidelines