Skip to main content
Known Participant
November 15, 2021
Answered

Drop down selections to emails

  • November 15, 2021
  • 2 replies
  • 2490 views

Hello,

If i have a drop down that has yes and no in it can I adjust the email body to show pre determined information if no is selected?

 

i.e. 

Are there scratches in panel work? "NO"

Email body: Warning, there are scratches in panel work

etc.

This topic has been closed for replies.
Correct answer try67

You can use something like this:

 

var emailBody = "";
if (this.getField("Are there scratches in panel work?").valueAsString=="NO")
	emailBody = "Warning, there are scratches in panel work";

this.mailDoc({cTo: "me@server.com", cSubject: "Email subject goes here", cMsg: emailBody});

2 replies

Bernd Alheit
Community Expert
Community Expert
November 17, 2021

What script does you use?

John CorfAuthor
Known Participant
November 22, 2021

var emailBody = "";
if (this.getField("1").valueAsString=="No")
emailBody = "Warning, there are scratches in panel work";

else if(this.getField("Serial No").value == "")
{
app.alert("Serial Number must be filled in");
}
else if(this.getField("Tyres").value == " ")
{
app.alert("Tyre size not selected");
}
else if(this.getField("Dropdown1").value == " ")
{
app.alert("Axle config not selected");
}


else if(this.getField("1").value == " ")
{
app.alert("Drawbar assembely cannot be left blank");
}
else if(this.getField("2").value == " ")
{
app.alert("Drawbar bolt kit cannot be left blank");
}
else if(this.getField("3").value == " ")
{
app.alert("Bale chute kit cannot be left blank");
}
else if(this.getField("4").value == " ")
{
app.alert("Computer kit cannot be left blank");
}
else if(this.getField("5").value == " ")
{
app.alert("C1000 harness cannot be left blank");
}
else if(this.getField("6").value == " ")
{
app.alert("Lighting/ Brake Harness kit cannot be left blank");
}
else if(this.getField("7").value == " ")
{
app.alert("Wide load boards cannot be left blank");
}
else if(this.getField("8").value == " ")
{
app.alert("Wide load board brakets cannot be left blank");
}
else if(this.getField("9").value == " ")
{
app.alert("Knotter flag kit cannot be left blank");
}
else if(this.getField("10").value == " ")
{
app.alert("Spares kits cannot be left blank");
}
else if(this.getField("11").value == " ")
{
app.alert("2290 Ladder kit cannot be left blank");
}
else if(this.getField("12").value == " ")
{
app.alert("pick up wheels cannot be left blank");
}
else if(this.getField("13").value == " ")
{
app.alert("Saftey Chain cannot be left blank");
}
else if(this.getField("14").value == " ")
{
app.alert("Beacon kit cannot be left blank");
}
else if(this.getField("15").value == " ")
{
app.alert("Operators manual cannot be left blank");
}
else if(this.getField("16").value == " ")
{
app.alert("EU Conformity cannot be left blank");
}
else
{// All is ok
this.mailDoc({cTo: "Email 1", cCc:"Email 2", cSubject: this.getField("Serial No").valueAsString, cMsg: emailBody})
}
;

Bernd Alheit
Community Expert
Community Expert
November 22, 2021

At the first if you set emailBody without sending the email:

 

if (this.getField("1").valueAsString=="No")
emailBody = "Warning, there are scratches in panel work";

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 15, 2021

You can use something like this:

 

var emailBody = "";
if (this.getField("Are there scratches in panel work?").valueAsString=="NO")
	emailBody = "Warning, there are scratches in panel work";

this.mailDoc({cTo: "me@server.com", cSubject: "Email subject goes here", cMsg: emailBody});
John CorfAuthor
Known Participant
November 16, 2021

Hello,

I cant seem to get it to work, it will email if the box is set to Yes however when set to No it will not submit?

also, is this method stackable i.e. if serveral selections are set to No will it put multi lines into the email?

try67
Community Expert
Community Expert
November 16, 2021

Are there any errors in the JS Console when you use it?

And yes, you can create multiple conditions, adding different texts to the email body string in each one.