Expand my Community achievements bar.

SOLVED

Email button scripting

Avatar

Level 9

I have a drop-down object (SupervisorList), a textfield (EmployeeEmail) and button object (SupervisorEmail). When the SupervisorEmail button is clicked, three things need to happen;

  1. The script needs to address an email message To the SupervisorList rawValue address
  2. Check to see if that address is one of three addresses (person1@company.com, person2@company.com or person3@company.com) and if yes, Cc: person4@company.com
  3. Also copy the EmployeeEmail address if not null.

I'm at a loss on how to accomplish this. This is my script:

Form1.Subform3.Approvals.Supervisor.SupervisorEmail::click - (JavaScript, client)

var vEmail;
var vSubject = "Vacation/Personal Leave Request";
var vBody = "Comments:"; 
var vCC;

if (EmployeeInfo.SupervisorList.rawValue !== null) {
     vEmail = EmployeeInfo.SupervisorList.rawValue;
}
if (this.rawValue == "person1@company.com" || this.rawValue == "person2@company.com" || this.rawValue == "person3@company.com"){
     "&cc" = "person4@company.com" + ";";
}
if (EmployeeInfo.EmployeeEmail.rawValue !== null){
     vCC = "&cc=" + EmployeeInfo.EmployeeEmail.rawValue;
}
else if (EmployeeInfo.EmployeeEmail.rawValue === null)  {
     vCC = "&cc=";
}
{
// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody + vCC,cSubmitAs:"PDF",cCharset:"utf-8"});
}

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I think you may have seen this example: http://assure.ly/dYQFb4.

If you have a look you will see how I deal with the CC part of the script. You certainly have an error there at the moment.

For example if the script is in the SupervisorEmail button, then it wont have a .rawValue. Therefore you need to refer to the dropdown AND not "this".

Also when setting the vCC variable, you need this:

var vCC = "";

Then you could deal with declaring of the vCC:

if (SupervisorList.rawValue == "person1@company.com" || SupervisorList.rawValue == "person2@company.com" || SupervisorList.rawValue == "person3@company.com") {

     vCC = "&cc" + "person4@company.com" + "; ";

}

if (EmployeeInfo.EmployeeEmail.rawValue !== null) {

     if (vCC == "") {

          vCC = "&cc=" + EmployeeInfo.EmployeeEmail.rawValue;

     }

     else {

          vCC = vCC + EmployeeInfo.EmployeeEmail.rawValue;

     }

}

Hope that helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

I think you may have seen this example: http://assure.ly/dYQFb4.

If you have a look you will see how I deal with the CC part of the script. You certainly have an error there at the moment.

For example if the script is in the SupervisorEmail button, then it wont have a .rawValue. Therefore you need to refer to the dropdown AND not "this".

Also when setting the vCC variable, you need this:

var vCC = "";

Then you could deal with declaring of the vCC:

if (SupervisorList.rawValue == "person1@company.com" || SupervisorList.rawValue == "person2@company.com" || SupervisorList.rawValue == "person3@company.com") {

     vCC = "&cc" + "person4@company.com" + "; ";

}

if (EmployeeInfo.EmployeeEmail.rawValue !== null) {

     if (vCC == "") {

          vCC = "&cc=" + EmployeeInfo.EmployeeEmail.rawValue;

     }

     else {

          vCC = vCC + EmployeeInfo.EmployeeEmail.rawValue;

     }

}

Hope that helps,

Niall

Avatar

Level 9

Yes, I have been reviewing those examples. Thank you for your help.

-Don