Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

CC Shows as null value and required field validation

Avatar

Level 2

Hi all,

I am using the following script attached to a button on my form:

var cToAddr = "gmdon@rogers.com";

var cCCAddr = Email1.rawValue;

var cBenAddr = Email2.rawValue; if(cBenAddr != "") cCCAddr += ";" + cBenAddr;

var cSubLine = "Form X-1 returned from client"; var cBody = "Thank you for submitting your form.\n" + "Save the mail attachment for your own records";

event.target.mailForm({

          bUI: true,

          cTo: cToAddr,

          cCc: cCCAddr,

          cSubject: cSubLine,

          cMsg: cBody

});

It works great unless nothing is entered into "Email1" or "Email2".  Then the email client shows "null" in the CC address field.  I'm wondering how to make it just leave CC blank if nothing is filled into either field?

I do have one other question.  When using the "standard submit button", it checks for a value in the 'required fields' and highlights them if they are not filled out.  I need to have dynamic CC addresses as you can see above so I can't use the standard button.  The question is how can I keep my required fields using this new button?

Sorry for being so wordy.  Thank you so much in advance for any assistance.

2 Replies

Avatar

Level 2

Hi all.  Everything fixed with this code.  Hope it helps someone else:

if (Parents_Name.rawValue == null || Agree.rawValue == "Off" || Date.rawValue == null){

xfa.host.messageBox("You must complete the required fields before trying to submit this form");

if (Parents_Name.rawValue == null){Parents_Name.fillColor = "0,255,0";}else{Parents_Name.fillColor = "255,255,255";}

if (Agree.rawValue == "Off"){Agree.fillColor = "0,255,0";}else{Agree.fillColor = "255,255,255";}

if (Date.rawValue == null){Date.fillColor = "0,255,0";}else{Date.fillColor = "255,255,255";}

}else{

var cToAddr = "gmdon@rogers.com";

var cCCAddr;

var cCCAddr2;

if (Email1.rawValue == null){cCCAddr = "";}else{cCCAddr = Email1.rawValue;}

if (Email2.rawValue == null){cCCAddr2 = "";}else{cCCAddr2 = Email2.rawValue;

cCCAddr += ";" + cCCAddr2;

}

var cSubLine = "Kids of Canada Registration Form";

var cBody = "Thank you for submitting your form.  All you have to do now is click send";

event.target.mailDoc({

          bUI: true,

          cTo: cToAddr,

          cCc: cCCAddr,

          cSubject: cSubLine,

          cMsg: cBody

});

}

Avatar

Level 2

Marty I am trying to use a portion of your script to send a PDF document via email.

The script I am using (shown below) calls the email but doesn't seem to recognize the email address I have noted in the var cToAddr.

When I select the submit button on the PDF I get the pop up screen, shown below.

Do you know what the issue might be?

checkname.PNG

// This is the form return e-mail. Its hardcoded

// so that the form is always returned to the same address

// Change address on your form

var cToAddr = "d123@123.com";

var cCCAddr;

var cCCAddr2;

// if (ClietEmail.rawValue == null){cCCAddr = "";}else{cCCAddr = ClietEmail.rawValue;}

// if (Email2.rawValue == null){cCCAddr2 = "";}else{cCCAddr2 = Email2.rawValue; cCCAddr += ";" + cCCAddr2;}

var cSubLine = "Crane Submission Form";

var cBody = "Thank you for submitting your form.  All you have to do now is click send";

event.target.mailDoc({

          bUI: true,

          cTo: cToAddr,

          cCc: cCCAddr,

          cSubject: cSubLine,

          cMsg: cBody

});