Copy link to clipboard
Copied
hello
i have 3 lines
this.getField("Sector2").value +"\n" +
this.getField("Sector3").value + "\n" +
this.getField("Sector4").value + "\n";
but sometime "Sector3" value equal empty so the line break still show like:
-sector2
-Sector4
i want remove the line break when "Sector3" value equal empty to be like:
-sector2
-sector4
thank you in advance
Then you need to append the values directly to the cBody string, like this:
...var cBody = "Thank you for submitting your report.\n\n" +
"CONTENT:\n\n" +
"- Dispatch Release Sector 1\n";
if (this.getField("Sector2").valueAsString!="")
cBody+="- Dispatch Release Sector 2: "+this.getField("Sector2").valueAsString+"\n";
if (this.getField("Sector3").valueAsString!="")
cBody+="- Dispatch Release Sector 3: "+this.getField("Sector3").valueAsString+"\n";
if (this.getField("Sector4").valueAsString!="")
Copy link to clipboard
Copied
You can do it like this:
var s = "";
if (this.getField("Sector2").valueAsString!="") s+=this.getField("Sector2").valueAsString+"\n";
if (this.getField("Sector3").valueAsString!="") s+=this.getField("Sector3").valueAsString+"\n";
if (this.getField("Sector4").valueAsString!="") s+=this.getField("Sector4").valueAsString+"\n";
The variable s will hold your full text at the end.
Copy link to clipboard
Copied
var D2 = "- Dispatch Release Sector 2";
var D3 = "- Dispatch Release Sector 3";
var D4 = "- Dispatch Release Sector 4";
var cBody = "Thank you for submitting your report.\n\n"
"CONTENT:"+ "\n\n" +
"- Dispatch Release Sector 1\n";
if (this.getField("Sector2").valueAsString!="") D2+=this.getField("Sector2").valueAsString+"\n";
if (this.getField("Sector3").valueAsString!="") D3+=this.getField("Sector3").valueAsString+"\n";
if (this.getField("Sector4").valueAsString!="") D4+=this.getField("Sector4").valueAsString+"\n";
i complete this script but it does not work, it that right ?
Copy link to clipboard
Copied
What do you intend for it to do, exactly?
Copy link to clipboard
Copied
body of email by this.mailDoc
Copy link to clipboard
Copied
Then you need to append the values directly to the cBody string, like this:
var cBody = "Thank you for submitting your report.\n\n" +
"CONTENT:\n\n" +
"- Dispatch Release Sector 1\n";
if (this.getField("Sector2").valueAsString!="")
cBody+="- Dispatch Release Sector 2: "+this.getField("Sector2").valueAsString+"\n";
if (this.getField("Sector3").valueAsString!="")
cBody+="- Dispatch Release Sector 3: "+this.getField("Sector3").valueAsString+"\n";
if (this.getField("Sector4").valueAsString!="")
cBody+="- Dispatch Release Sector 4: "+this.getField("Sector4").valueAsString+"\n";
this.mailDoc({cMsg: cBody});
Copy link to clipboard
Copied
i will try
Copy link to clipboard
Copied
you are awesome
it workssss
thank you so much
Copy link to clipboard
Copied
//
// Before sending the data, make sure that all required
// fields are valid
//
// The "Ex2ValidFields" fucntion is located in the document script
// If you copy this button action then you will also need to delete
// this first if statement or copy the "Ex2ValidFields()"
// fucntion and modify it to work with your form.
//
if(Ex2ValidFields())
{
// This is the form return email, It’s hardcoded
// so that the form is always returned to the same address
// Change address on your form
var cToAddr = this.getField("A/C TYPE").value;
// First, get the client CC email address
var cCCAddr ="";
// Now get the beneficiary email only if it is filled out
// Set the subject line for the email message
var cSubLine = this.getField("A/C REG").value+ " FLIGHT ENVELOPE";
// Set the body text for the email message
var f = this.getField("A/C TYPE");
var a = f.currentValueIndices;
var cBody = "Thank you for submitting your report.\n\n"
+ "Date: " + this.getField("Date").value + "\n"
+ "Aircraft type: " + f.getItemAt(a, false) + "\n"
+ "Aircraft registration: "
+ this.getField("A/C REG").value + "\n"
+ "Route: " + this.getField("FROM1").value + "-"
+ this.getField("TO1").value + "-"
+ this.getField("TO2").value + "-"
+ this.getField("TO3").value + "-"
+ this.getField("TO4").value + "\n\n" +
"CONTENT:"+ "\n\n" +
"- Dispatch Release Sector 1\n" +
this.getField("Sector2").value +"\n" +
this.getField("Sector3").value + "\n" +
this.getField("Sector4").value + "\n";
// Send the entire PDF as a file attachment on an e-mail
this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr,
cSubject: cSubLine, cMsg: cBody});
}
sometimes value of "Sector3" is empty, so how we delete or skip the empty line
and make it like
-sector2
-sector4
Copy link to clipboard
Copied
I answered that already.