Skip to main content
Participant
October 2, 2024
Question

Creating a submit form- check box values into subject line

  • October 2, 2024
  • 2 replies
  • 242 views

I'm creating a form that submits a filled out PDF to a specific email. I have three check boxes, if one is selected that value goes into the subjectline.

 

The code I'm using right now is:

 

var targetEmail = "name@name.com";

var subjectLine = "Material Determination Transition Form Received for Plant(s) - " + " " + this.getField("Check Box 21").valueAsString + " " + this.getField("Check Box 22").valueAsString + " " + this.getField("Check Box 23").valueAsString;

this.mailDoc({cTo: targetEmail, cSubject: subjectLine});
(function () {

 

When I tested it, I checked two boxes and the subject line reads:

Material Determination Transition Form Received for Plant(s) - Off 2100 2200

 

The unchecked box leaves a value of "Off" in the subject line. If anyone can help in either hiding the Off or to change the unchecked value of all the check boxes to a blank would be greatly appreciated. Ty!

2 replies

try67
Community Expert
Community Expert
January 23, 2025

Try this:

 

var targetEmail = "name@name.com";
var values = [];
var v1 = this.getField("Check Box 21").valueAsString;
if (v1!="Off") values.push(v1);
var v2 = this.getField("Check Box 22").valueAsString;
if (v2!="Off") values.push(v2);
var v3 = this.getField("Check Box 23").valueAsString;
if (v3!="Off") values.push(v3);
var subjectLine = "Material Determination Transition Form Received for Plant(s) - " + values.join(" ");
this.mailDoc({cTo: targetEmail, cSubject: subjectLine});
Legend
January 23, 2025

Hi, 


Sorry for the delay in responding to your question. I am inviting the top experts in this domain to update this discussion.
Hi, @try67   @Nesa Nurani, kindly check if you could add your thoughts on this for future visitors. 

 


~Tariq