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})
}
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.
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
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});
}
Copy link to clipboard
Copied
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.