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

ADOBE JAVASCRIPTS

New Here ,
Jun 18, 2018 Jun 18, 2018

I currently have this script running :

var patternEmpty = /^\s*$/;

var strMissing = "";

if(patternEmpty.test(this.getField("1st
purchaser").value))

     strMissing =
"1st purchaser";

  { // All is ok,
submit the data

  1. console.println("All form data ok");

  }

if(strMissing.length)

{// Got an error

  1. app.alert("Please complete 1st Purchaser: " +
    strMissing);

}

NEED this

var cToAddr =
"
Pcardreceipts@ifas.ufl.edu";

var cCCAddr =
this.getField("Email").value;

var cSubLine = " P-CARD FORM SUBMITTED FOR PROCESSING";
  1. this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr,
    cSubject: cSubLine,});

I want to merge script below into the above script or should it be written as one script and if any recommendations would be appreciated....?

var cToAddr =
"
Pcardreceipts@ifas.ufl.edu";

var cCCAddr =
this.getField("Email").value;

var cSubLine = " P-CARD FORM SUBMITTED FOR PROCESSING";
var cBody = " Thank you for funding this purchase.\n" + "We Appreciate your support";
  1. this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr,
    cSubject: cSubLine, cMsg: cBody});
TOPICS
Acrobat SDK and JavaScript , Windows
2.1K
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 , Jul 06, 2018 Jul 06, 2018

I'll give you a hint: JavaScript is case-sensitive...

Translate
LEGEND ,
Jun 18, 2018 Jun 18, 2018

It can replace the corresponding lines in the original. The only difference is setting a message body.

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 ,
Jun 18, 2018 Jun 18, 2018

attempted your recommendations with no success.  Here is what i am attempting to accomplish,  I need the form to email the originator, if the email field (not required) is populated upon the approver using the submit (ADMIN) button for processing.  This button has the JavaScript to validate the 1st purchaser field before it will permit the form to be submitted using the ADMIN button.   I want to ad the var cCCaddr = this.getField ("Email") . value;  in the existing script yet can seem to place it in the correct place....

to clarify, the admin button has the mailto action set to the To: address and includes a JavaScript to validate field "1st purchaser" before the form can be sent for processing...  I want to add the "Email" field as cc when populated upon selecting the ADMIN button for processing to the existing JavaScript.

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
LEGEND ,
Jun 18, 2018 Jun 18, 2018

If you would like us to take a look please post the exact revised script, and look in the console: please copy and paste any errors.

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 ,
Jun 18, 2018 Jun 18, 2018

var patternEmpty = /^\s*$/;

var strMissing = "";

if(patternEmpty.test(this.getField("1st purchaser").value))

     strMissing = "1st purchaser";

   { // All is ok, submit the data

console.println("All form data ok");

  }

if(strMissing.length)

{// Got an error

app.alert("Please complete 1st Purchaser: " + strMissing);

}

var cToAddr = " Pcardreceipts@ifas.ufl.edu";

var cCCAddr = this.getField("Email").value;

var cSubLine = "P-CARD RECIEPT FORM SUBMITTED FOR PROCESSING ";

var cBody = "Thank you for submitting your form.\n" + "Save the mail attachment for your own records";

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

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
Community Expert ,
Jun 19, 2018 Jun 19, 2018

HI,

The code you have posted works as I would expect, if I fill in the "1st purchaser" field and enter an email address in the email field, then once I click the button, I get an email generated with the contents of the email field in the CC section.

If I don't fill in the "1st purchaser" field, I get a dialog that says I should, and then it creates the email anyway, not sure this is what you want to happen?

Regards

Malcolm

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 ,
Jun 19, 2018 Jun 19, 2018

almost there....  If the 1st purchaser isn't filled in the error message should appear requiring the person to go back and enter in the info required and then and only then should the email open....

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
Community Expert ,
Jun 19, 2018 Jun 19, 2018

Hi,

In that case you just need to add an else to your if statement.

So you code will become

var patternEmpty = /^\s*$/;

var strMissing = "";

if(patternEmpty.test(this.getField("1st purchaser").value))

     strMissing = "1st purchaser";

   { // All is ok, submit the data

console.println("All form data ok");

  }

if(strMissing.length)

{// Got an error

app.alert("Please complete 1st Purchaser: " + strMissing);

}

else

{

var cToAddr = " Pcardreceipts@ifas.ufl.edu";

var cCCAddr = this.getField("Email").value;

var cSubLine = "P-CARD RECIEPT FORM SUBMITTED FOR PROCESSING ";

var cBody = "Thank you for submitting your form.\n" + "Save the mail attachment for your own records";

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

}

 

  This means that you alert will be shown OR your mail will be created, not both.

Hope this helps

Malcolm

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 ,
Jun 19, 2018 Jun 19, 2018

that is working for the error message desired however, the CC is not populating from the this.getField ("Email") .value?

I do appreciate your assistance with this..  I am copying and pasting into the JavaScript so that i am not making a typo....

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
Community Expert ,
Jun 19, 2018 Jun 19, 2018

HI,

What are you using to send the mail? as it works on osx with the default mail app.

Regards

Malcolm

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 ,
Jun 19, 2018 Jun 19, 2018

ah ha....  we use PC windows 10, exchange (outlook)  not Mac

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 ,
Jul 06, 2018 Jul 06, 2018

Ok, as requested I am using original forum.....

I have copied and pasted the above script into the Mouseup JavaScript and the Onblur as well and it doesn't open an email window... If i create the Mouse up Submit a Form  and enter in the mailto:xxxxxx and then insert the java script the validation of the required field completes and if it is populated the email window opens but it is not recognizing the cc: Email field any suggestions?  I really all appreciate all of the responses to date.  Just haven't been able to get the results desired....

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
Community Expert ,
Jul 06, 2018 Jul 06, 2018

So there are no error messages or anything and the email is generated, but the CC field is empty?

Silly question, but did you actually fill in the "Email" field?

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 ,
Jul 06, 2018 Jul 06, 2018

No question is silly, but yes I place my email address in the Email field.  nope no errors....  Now remind you that this is when I have two actions set...  the first is the Submit a Form with the To: address completed and then the JavaScript inserted as On Blur....  the validation occurs and if the required field is populated, an email pops up with the cc: block blank

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
Community Expert ,
Jul 06, 2018 Jul 06, 2018

You should not be using a Submit Form command. The JavaScript code does that already.

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 ,
Jul 06, 2018 Jul 06, 2018

I understand as I have another form and the Var javascript is working as advertised. In this particular form it opens nothing, I have to insert the Submit a Form to get the email option.    Now the other form I am referring to only has the JavaScript for submission of the form and cc: the originator, it is not combining the validation of another field before allowing the submission.

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 ,
Jul 06, 2018 Jul 06, 2018

If I remove the Validation Script the form opens an email and the To: and Cc: boxes are populated…. I am thinking something with the validation script for the required field is not exactly right?

Russell L Hunter

IT Professional II

University of florida

Ifas/north florida research and education center

Quincy/Marianna

155 research road

Quincy florida, 32351

850-875-7124

“todays dreams are tomorrows future”

Author unknown

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 ,
Jul 06, 2018 Jul 06, 2018

anyone else have suggestions?  I need the required field to be populated before it will allow the approver to send the form for processing. (the original script for that is working).   I would like to have it cc: the originator upon it being sent for processing so they can track its progression.....   as mentioned earlier the revised script above should work however, if I don't insert the Submit a Form option it is not opening the email page to submit nor is it validating the required field... when using the javascript (Mouse Up), outcome is nothing happens.  no error, no email, no notification that the required field isn't filled in.

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
Community Expert ,
Jul 06, 2018 Jul 06, 2018

You should debug your code in the console.

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 ,
Jul 06, 2018 Jul 06, 2018

ok will give that a try

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 ,
Jul 06, 2018 Jul 06, 2018

Acrobat JavaScript Debugger Functions Version 11.0
Acrobat EScript Built-in Functions Version 11.0
Acrobat SOAP 11.0

this.getField("1st purchaser") is null
3:Field:Mouse Up
TypeError: this.getField("1st purchaser") is null
3:Field:Mouse Up

explanation please?  i haven't changed anything with this script to cause this error that I know of.....

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
Community Expert ,
Jul 06, 2018 Jul 06, 2018

That error means there's no field with that name in your file...

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
Community Expert ,
Jul 06, 2018 Jul 06, 2018

In your form there no field with this name.

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 ,
Jul 06, 2018 Jul 06, 2018

but there is I promise

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
Community Expert ,
Jul 06, 2018 Jul 06, 2018

Look carefully at the name and at what you entered in the script...

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