• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

If text field if blank, skip

New Here ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

Hi,

I am working on a PDF form when the send button is clicked, certain information is transferred to the body of the email. What I am having issues or can't figure out is, if I have a blank text box or selection, I want it to be skipped and not transferred to the body of the email. The name of the text boxes are 1.OM 2. BOV 3. Blast. The input will be placed after ".getField("Document Orientation") the code is below:

// JavaScript Document

{
   var cToAddr = this.getField("designer").value;

   // Set the subject line
   var cSubLine = "Graphic Request" + " " + this.getField("Project Name").value;

    //this is what will be displayed in the body of the email
    var cBody = "Hi,"
                + "\n\n"
                + "Project leader for the request:"
                + "\n"
                + this.getField("Project_Lead_1").value + " "
                + "\n"
                + this.getField("Project_Lead_2").value + " "
                + "\n\n"
                + "The name of the project is" + " "
                + this.getField("Project Name").value + "."
                + "\n"
                + "Comments:" + " " + this.getField("Comments").value
                + "\n\n"
                + "Document of Type:"
                + "\n"
                + this.getField("Type").value + ", " + this.getField("Document Size").value + ", "
                + this.getField("Document Orientation").value;

   // Send the entire PDF as a file attachment on an e-mail
   this.mailDoc({bUI:true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody});

}

TOPICS
PDF forms

Views

878

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

correct answers 1 Correct answer

Community Expert , Nov 18, 2017 Nov 18, 2017

Yes, it is. Set the value you want to display as the export value (or "radio choice value") of the field, and then use this code:

if (this.getField("OM").valueAsString!="Off") cBody+=this.getField("OM").valueAsString+"\n";

Votes

Translate

Translate
Community Expert ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

Use something like this:

if (this.getField("OM").valueAsString!="") cBody+=this.getField("OM").valueAsString+"\n";

Votes

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
New Here ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

Thank you for your quick response. I added the code but now its coming up as "off".

Votes

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
New Here ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

sorry, hit the button by mistake. When the check box is not selected, it is showing up as "off" on the email. Also, if the check box is selected, its showing up as "yes" instead of the selection.

Votes

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 Expert ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

You said it was a text field...

Votes

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
New Here ,
Nov 18, 2017 Nov 18, 2017

Copy link to clipboard

Copied

Sorry if that wasn’t clear enough. Can it be done with  radio or check boxes?

Votes

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 Expert ,
Nov 18, 2017 Nov 18, 2017

Copy link to clipboard

Copied

LATEST

Yes, it is. Set the value you want to display as the export value (or "radio choice value") of the field, and then use this code:

if (this.getField("OM").valueAsString!="Off") cBody+=this.getField("OM").valueAsString+"\n";

Votes

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