I want to update some case fields and populate an email template via a custom JavaScript button. Thanks to your answers to questions in the stackexchange, I created buttons that do that but send out the email at the same time. My question: is it possible to first update everything, and then letting the agent confirm by clicking on send email (so instead of send email just update)? One of my current buttons:
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")}
(function() {
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.Status = 'Closed';
caseObj.Reason = 'Example Reason';
var result = sforce.connection.update([caseObj]);
sforce.connection.sessionId = "{!$Api.Session_ID}";
var message = new sforce.SingleEmailMessage();
message.replyTo = "[email protected]";
message.senderDisplayName = "[email protected]";
message.targetObjectId = "{!Contact.Id}";
message.templateId = "template ID";
var result = sforce.connection.**sendEmail**([message]);
if(result[0].success) {
alert("You have sent an email regarding Example Reason");
} else {
alert("Your email was not sent. Please contact XYZ");
}
window.location.href=window.location.href;
}());
Thanks in advance!!