Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Trying to get my PDF to look two fields to determin if it is ready to be emailed.

Community Beginner ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

Here is the code that I have. I can't get it to work. What i want it to do is look at Applicant Type and the Justificaion Field. If Applicant Type is Contractor and the Justification Field is blank then a message alert opends. If not then send an email and look at other fields to fill out the Subject, and Body of that email.

 

var Appl=this.getfield("applicant type").valueAsString;
var ConJ=this.getfield("ConJustification").valueAsString;

if ((Appl == "Contractor")&&(ConJ == "")); {
app.alert("Please enter justification for badge in the additional information box below.");
}
else {
var ctoaddr=("MyEmailGoesHere@Email.com");
var csubline=("Badge Request for ") + this.getfield("Last name").value + ", " + this.getfield("First Name");
var cBody=" Hello please see the attached " + csubline;

this.maildoc({bUI: true,Cto:cToAddr, cSubject:cSubLine, cMsg:cBody})
}

TOPICS
How to, JavaScript

Views

41

Likes

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
Adobe Community Professional ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

Remove the semi-colon after the if-condition.

 

Also, you have a spelling mistake in the name of the csubline variable. You're referring to it later on as cSubLine, which is not the same (remember that JS is case-sensitive!). Same goes for ctoaddr and cToAddr.

Likes

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 Beginner ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

Thank you I did not catch that. I fixed it in my code. But it still gives me an error

Likes

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 Beginner ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

Okay I found some Errors that I did not see. The code below is what I have now, I put it in the properties On Focus run JavaScript. But when I click the button it does nothing now. 

 

var Appl = this.getfield("applicant type").valueAsString;
var ConJ = this.getfield("ConJustification").valueAsString;
var cToAddr = ("LSSAccessRequest@dshs.texas.gov").valueAsString;
var cSubLine = ("Badge Request for ") + this.getfield("Last name").value + ", " + this.getfield("First Name").valueAsString;
var cBody = ("Hello please see the attached ") + cSubLine;

if ((Appl === "Contractor") && (ConJ === "")) {
'app'.alert('Please enter justification for badge.');
} else {
this.mailTo({bUI: true, Cto: cToAddr, cSubject: cSubLine, cMsg: cBody});
}

Likes

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
Adobe Community Professional ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

LATEST

You still have a lot of errors in your code. Check the JS Console and you'll see something like this repeated multiple times:

 

TypeError: this.getfield is not a function


The reason is the method is called getField, not getfield...

Also, why did you put quotes around 'app'?

And there's no method called mailTo. Use mailDoc.

And it's not Cto, but cTo.

 

Likes

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