Copy link to clipboard
Copied
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
}
if(strMissing.length)
{// Got an error
}
NEED this
var cToAddr =
" Pcardreceipts@ifas.ufl.edu";
var cCCAddr =
this.getField("Email").value;
var cSubLine = " P-CARD FORM SUBMITTED FOR PROCESSING";
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";
I'll give you a hint: JavaScript is case-sensitive...
Copy link to clipboard
Copied
It can replace the corresponding lines in the original. The only difference is setting a message body.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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});
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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....
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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....
Copy link to clipboard
Copied
HI,
What are you using to send the mail? as it works on osx with the default mail app.
Regards
Malcolm
Copy link to clipboard
Copied
ah ha.... we use PC windows 10, exchange (outlook) not Mac
Copy link to clipboard
Copied
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....
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
You should not be using a Submit Form command. The JavaScript code does that already.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You should debug your code in the console.
Copy link to clipboard
Copied
ok will give that a try
Copy link to clipboard
Copied
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.....
Copy link to clipboard
Copied
That error means there's no field with that name in your file...
Copy link to clipboard
Copied
In your form there no field with this name.
Copy link to clipboard
Copied
but there is I promise
Copy link to clipboard
Copied
Look carefully at the name and at what you entered in the script...