These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Checkbox export value

MMWilliams
Registered: Aug 23 2010
Posts: 16
Answered

I have a series of checkboxes that I want to adjust the export value on, when exporting into an email body.
 
I have them set to the value I want when checked, but there seems to be some sort of default setting I can't adjust that exports the value of "off" when the box is unchecked.
 
I would rather the data not appear at all if the box is unchecked.
 
Has anyone dealt with this?
 
Thanks

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Actually, the value is "Off". There's nothing you can do apart from not exporting the field at all, depending on how you're doing the export.
MMWilliams
Registered: Aug 23 2010
Posts: 16
Is there a script that will only export the value when the box is checked?


George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
How exactly are you exporting the data? What are you doing with the data once it's exported?
MMWilliams
Registered: Aug 23 2010
Posts: 16
I'm exporting the data into an email using app.mailMsg and just pulling from all the fields I want in the email.

I'm not familiar enough with the process to be able to articulate this clearly, can I send you the form to look at and explain from there?
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
If you're using mailMsg, you must be getting the field values in a script when creating the body of the email. You just need to check the value of the field, and if it's "Off", don't include it. If you get stuck, post the script here or post the form somewhere, and someone here should be able to help.
MMWilliams
Registered: Aug 23 2010
Posts: 16
Here is the script for getting the field values in question:

var membershipstatusretv = this.getField("Membership Status RET");
var membershipstatusffsv = this.getField("Membership Status FFS");
var membershipstatuscorpv = this.getField("Membership Status CORP");
var membershipstatusotherv = this.getField("Membership Status OTHER");

I then have this in the email body formatting:

emailBody += membershipstatusretv.value + " " + membershipstatusffsv.value + " " + membershipstatuscorpv.value + " " + membershipstatusotherv.value + "\r\n";

All I've been able to figure out is how to pull the field data. If the checkbox is not checked, the email is formatted like this:

"MEMBERSHIP STATUS:
RET Off Off Off"

I would prefer it only list the specified export values listed (RET FFS CORP OTHER) and leave the unchecked fields blank so the result would read:

MEMBERSHIP STATUS:
RET


Is that doable?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
When a check box is not selected the export value is "Off", so you must account for this. You can modify how you get the values with the following script:

var membershipstatusretv = this.getField("Membership Status RET").value;
if(membershipstatusretv == "Off") membershipstatusretv = ""; // if Off null value
var membershipstatusffsv = this.getField("Membership Status FFS").value;
if(membershipstatusffsv == "Off) membershipstatusffsv = ""; // if Off null value
var membershipstatuscorpv = this.getField("Membership Status CORP").value;
if(membershipstatuscorpv == 'Off') membershipstatuscorpv = ""; // if Off null value
var membershipstatusotherv = this.getField("Membership Status OTHER").value;
if(membershipstatusotherv == "Off") membershipstatusotherv = ""; // if Off null value

You will have to modify the rest of your script, since I am using the value in the variable and not the field object.

George Kaiser

MMWilliams
Registered: Aug 23 2010
Posts: 16
Thanks George.

I'm now getting the fields reading "undefined" for both checked and unchecked, but I think because I'm not sure where to modify the rest of the script?
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Change the line to:

emailBody += membershipstatusretv + " " + membershipstatusffsv + " " + membershipstatuscorpv + " " + membershipstatusotherv + "\r\n";

MMWilliams
Registered: Aug 23 2010
Posts: 16
Perfect. Thanks both of you guys!