Skip to main content
Known Participant
Nov 15, 2021 4:14 PM UTC
Answered

Drop down selections to emails

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Nov 15, 2021 7:23 PM UTC

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});

30 replies

Bernd Alheit
Community Expert
Community Expert
Nov 17, 2021 10:20 AM UTC

What script does you use?

Translate
John CorfAuthor
Known Participant
Nov 22, 2021 10:51 AM UTC

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})
}
;

Translate
Bernd Alheit
Community Expert
Community Expert
Nov 22, 2021 11:12 AM UTC

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";

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Nov 15, 2021 7:23 PM UTC

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});
Translate
John CorfAuthor
Known Participant
Nov 16, 2021 10:50 AM UTC

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?

Translate
try67
Community Expert
Community Expert
Nov 16, 2021 12:39 PM UTC

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.

Translate