You need to sign in to do that
Don't have an account?
Yunus Kalam
How to send email template conditionally ?
Hello,
I have created a custom button on Opportunity. The custom button has following javascript code. When the user clicks on the button, the email should be sent. And it is working fine. But i want to send email conditionally like if(Stage = "Provisional - Awaiting Deposit") then this custom button should send an email.
Any suggestion would be helpful.
Thank you,
Yunus Kalam
I have created a custom button on Opportunity. The custom button has following javascript code. When the user clicks on the button, the email should be sent. And it is working fine. But i want to send email conditionally like if(Stage = "Provisional - Awaiting Deposit") then this custom button should send an email.
Any suggestion would be helpful.
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} (function() { sforce.connection.sessionId = "{!$Api.Session_ID}"; var message = new sforce.SingleEmailMessage(); message.targetObjectId = "{!Opportunity.ContactId__c}"; message.templateId = "00X7E000000EF6w"; message.whatId = "{!Opportunity.Id}"; message.saveAsActivity = true; var result = sforce.connection.sendEmail([message]); if(result[0].success == 'true') { alert("Email has sent succesfully..."); } else { alert("Failed..."); } alert(result); }());
Thank you,
Yunus Kalam
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
(function() {
var oppStage = "{!Opportunity.stageName}";
if(oppStage == "Provisional - Awaiting Deposit"){
sforce.connection.sessionId = "{!$Api.Session_ID}";
var message = new sforce.SingleEmailMessage();
message.targetObjectId = "{!Opportunity.ContactId__c}";
message.templateId = "00X7E000000EF6w";
message.whatId = "{!Opportunity.Id}";
message.saveAsActivity = true;
var result = sforce.connection.sendEmail([message]);
if(result[0].success == 'true') {
alert("Email has sent succesfully...");
} else {
alert("Failed...");
}
alert(result);
}
}());