Skip to main content
Participant
October 9, 2019
Answered

Sharing info - Adobe Javascript Create email list based on checkbox's

  • October 9, 2019
  • 1 reply
  • 557 views

Hi,

I have been scouring the internet to find a way to populate a list of email addresses based on checkboxes being checked and placed in the CC field, so far I have found nothing, however I have worked out how to do this myself and thought that I would share.

 

I have 12 Checkboxes, in the properties of each, the export value is the email address. The following code also does some other functions, such as allow the user to search the global address book or contacts for the To: email address There is also  custom var data in the Subject also pulling info from form fields, as well as data for the body of the email. Hope this helps someone.

 

var sendForm = app.alert("Are you sure you want  to submit this form?",2,2,"Submit Form");

//Below is the variable for each check box, check and see if it is checked.
if(this.getField("MD").value == "Off"){
    var eMcc1 = ";" 
} else {
    var eMcc1 = this.getField("MD").value + ";"
}   	

if(this.getField("TC").value == "Off"){
    var eMcc2 = ";"
} else {
    var eMcc2 = this.getField("TC").value + ";"
}  

if(this.getField("PH").value == "Off"){
    var eMcc3 = ";"
} else {
    var eMcc3 = this.getField("PH").value + ";"
}   	

if(this.getField("DH").value == "Off"){
    var eMcc4 = ";"
} else {
    var eMcc4 = this.getField("DH").value + ";"
}   	

if(this.getField("ML").value == "Off"){
    var eMcc5 = ";"
} else {
    var eMcc5 = this.getField("ML").value + ";"
}   	

if(this.getField("CW").value == "Off"){
    var eMcc6 = ";"
} else {
    var eMcc6 = this.getField("CW").value + ";"
}   	

if(this.getField("JH").value == "Off"){
    var eMcc7 = ";"
} else {
    var eMcc7 = this.getField("JH").value + ";"
}   	

if(this.getField("CK").value == "Off"){
    var eMcc8 = ";"
} else {
    var eMcc8 = this.getField("CK").value + ";"
}   	

if(this.getField("GK").value == "Off"){
    var eMcc9 = ";"
} else {
    var eMcc9 = this.getField("GK").value + ";"
}   	

if(this.getField("IV").value == "Off"){
    var eMcc10 = ";"
} else {
    var eMcc10 = this.getField("IV").value + ";"
}   	

if(this.getField("PAYROLL").value == "Off"){
    var eMcc11 = ";"
} else {
    var eMcc11 = this.getField("PAYROLL").value + ";"
}   	

if(this.getField("HR").value == "Off"){
    var eMcc12 = ";"
} else {
    var eMcc12 = this.getField("HR").value + ";"
}   	

//concatenate variables into one.
var eCCm = eMcc1 + eMcc2 + eMcc3 + eMcc4 + eMcc5 + eMcc6 + eMcc7 + eMcc8 + eMcc9 + eMcc10 + eMcc11 + eMcc12

//Custom Subject line, inc fields from form
var eSub = "IT Access form for - " + this.getField("FirstName").value + " " + this.getField("LastName").value + " " + this.getField("Date2").value

//Custom body, inc fields from form
var eMsg = "Please see attached IT Access form for processing, when completed please return to " + this.getField("ManagerName").value + " with the username and Password."

if(sendForm == 4){
    sendWhere = app.response({cMsg:"Where do you want to send the form?",cTitle:"Where should the form be sent",cLabel:"Name or Email Address"});
    this.mailDoc({bUI:true, cTo:sendWhere, cCc: eCCm, cSubject:eSub, cMsg:eMsg});
}
else
    app.alert("You have canceled the submisson, and the form has not been sent.");

 

This topic has been closed for replies.
Correct answer Dano78
var sendForm = app.alert("Are you sure you want  to submit this form?",2,2,"Submit Form");

//Below is the variable for each check box, check and see if it is checked.
if(this.getField("MD").value == "Off"){
    var eMcc1 = ";" 
} else {
    var eMcc1 = this.getField("MD").value + ";"
}   	

if(this.getField("TC").value == "Off"){
    var eMcc2 = ";"
} else {
    var eMcc2 = this.getField("TC").value + ";"
}  

if(this.getField("PH").value == "Off"){
    var eMcc3 = ";"
} else {
    var eMcc3 = this.getField("PH").value + ";"
}   	

if(this.getField("DH").value == "Off"){
    var eMcc4 = ";"
} else {
    var eMcc4 = this.getField("DH").value + ";"
}   	

if(this.getField("ML").value == "Off"){
    var eMcc5 = ";"
} else {
    var eMcc5 = this.getField("ML").value + ";"
}   	

if(this.getField("CW").value == "Off"){
    var eMcc6 = ";"
} else {
    var eMcc6 = this.getField("CW").value + ";"
}   	

if(this.getField("JH").value == "Off"){
    var eMcc7 = ";"
} else {
    var eMcc7 = this.getField("JH").value + ";"
}   	

if(this.getField("CK").value == "Off"){
    var eMcc8 = ";"
} else {
    var eMcc8 = this.getField("CK").value + ";"
}   	

if(this.getField("GK").value == "Off"){
    var eMcc9 = ";"
} else {
    var eMcc9 = this.getField("GK").value + ";"
}   	

if(this.getField("IV").value == "Off"){
    var eMcc10 = ";"
} else {
    var eMcc10 = this.getField("IV").value + ";"
}   	

if(this.getField("PAYROLL").value == "Off"){
    var eMcc11 = ";"
} else {
    var eMcc11 = this.getField("PAYROLL").value + ";"
}   	

if(this.getField("HR").value == "Off"){
    var eMcc12 = ";"
} else {
    var eMcc12 = this.getField("HR").value + ";"
}   	

//concatenate variables into one.
var eCCm = eMcc1 + eMcc2 + eMcc3 + eMcc4 + eMcc5 + eMcc6 + eMcc7 + eMcc8 + eMcc9 + eMcc10 + eMcc11 + eMcc12

//Custom Subject line, inc fields from form
var eSub = "IT Access form for - " + this.getField("FirstName").value + " " + this.getField("LastName").value + " " + this.getField("Date2").value

//Custom body, inc fields from form
var eMsg = "Please see attached IT Access form for processing, when completed please return to " + this.getField("ManagerName").value + " with the username and Password."

if(sendForm == 4){
    sendWhere = app.response({cMsg:"Where do you want to send the form?",cTitle:"Where should the form be sent",cLabel:"Name or Email Address"});
    this.mailDoc({bUI:true, cTo:sendWhere, cCc: eCCm, cSubject:eSub, cMsg:eMsg});
}
else
    app.alert("You have canceled the submisson, and the form has not been sent.");

1 reply

Dano78AuthorCorrect answer
Participant
October 9, 2019
var sendForm = app.alert("Are you sure you want  to submit this form?",2,2,"Submit Form");

//Below is the variable for each check box, check and see if it is checked.
if(this.getField("MD").value == "Off"){
    var eMcc1 = ";" 
} else {
    var eMcc1 = this.getField("MD").value + ";"
}   	

if(this.getField("TC").value == "Off"){
    var eMcc2 = ";"
} else {
    var eMcc2 = this.getField("TC").value + ";"
}  

if(this.getField("PH").value == "Off"){
    var eMcc3 = ";"
} else {
    var eMcc3 = this.getField("PH").value + ";"
}   	

if(this.getField("DH").value == "Off"){
    var eMcc4 = ";"
} else {
    var eMcc4 = this.getField("DH").value + ";"
}   	

if(this.getField("ML").value == "Off"){
    var eMcc5 = ";"
} else {
    var eMcc5 = this.getField("ML").value + ";"
}   	

if(this.getField("CW").value == "Off"){
    var eMcc6 = ";"
} else {
    var eMcc6 = this.getField("CW").value + ";"
}   	

if(this.getField("JH").value == "Off"){
    var eMcc7 = ";"
} else {
    var eMcc7 = this.getField("JH").value + ";"
}   	

if(this.getField("CK").value == "Off"){
    var eMcc8 = ";"
} else {
    var eMcc8 = this.getField("CK").value + ";"
}   	

if(this.getField("GK").value == "Off"){
    var eMcc9 = ";"
} else {
    var eMcc9 = this.getField("GK").value + ";"
}   	

if(this.getField("IV").value == "Off"){
    var eMcc10 = ";"
} else {
    var eMcc10 = this.getField("IV").value + ";"
}   	

if(this.getField("PAYROLL").value == "Off"){
    var eMcc11 = ";"
} else {
    var eMcc11 = this.getField("PAYROLL").value + ";"
}   	

if(this.getField("HR").value == "Off"){
    var eMcc12 = ";"
} else {
    var eMcc12 = this.getField("HR").value + ";"
}   	

//concatenate variables into one.
var eCCm = eMcc1 + eMcc2 + eMcc3 + eMcc4 + eMcc5 + eMcc6 + eMcc7 + eMcc8 + eMcc9 + eMcc10 + eMcc11 + eMcc12

//Custom Subject line, inc fields from form
var eSub = "IT Access form for - " + this.getField("FirstName").value + " " + this.getField("LastName").value + " " + this.getField("Date2").value

//Custom body, inc fields from form
var eMsg = "Please see attached IT Access form for processing, when completed please return to " + this.getField("ManagerName").value + " with the username and Password."

if(sendForm == 4){
    sendWhere = app.response({cMsg:"Where do you want to send the form?",cTitle:"Where should the form be sent",cLabel:"Name or Email Address"});
    this.mailDoc({bUI:true, cTo:sendWhere, cCc: eCCm, cSubject:eSub, cMsg:eMsg});
}
else
    app.alert("You have canceled the submisson, and the form has not been sent.");