function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
icejohn2508icejohn2508 

Create Button on Case E-Mail Template "Send E-Mail Close Case"

Hello All,

 

Our support agents our requesting a "Custom Button" on the Case E-Mail template.  What they would like is the ability to click a "Send E-Mail and Close Case" button.  Once clicked the e-mail would be sent to the customer and the agent would be redirected to the Case Close page.

 

Has anyone tackled a similar request?  I am a novice to Apex Code and Visualforce, so any assistance is greatly appreciated.

 

Thanks,

Alex.AcostaAlex.Acosta

Javascript will help you a lot with this task... make sure you have to execute javascript when button is clicked.

 

Here's a very basic example running on an Opportunty Record: (Keep in mind it's not doing anything, but it can give you a head start on what you want to do)

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")} 

// error message to use on alert box in case of something going awry var alertMessage = '';

// Making query call var contactResult = sforce.connection.query("SELECT Id, FirstName, LastName, Email FROM Contact WHERE AccountId = '{!Opportunity.AccountId}'");

// expecting a single record, and pulling it from the returned list var contactRecord = contactResult.getArray('records')[0];
// example of a use case for why you need to alert the user if something is wrong if(null == contactRecord.Email){ alertMessage = 'Error Message Here'; }
// show error message and do nothing if there is an error if('' != alertMessage){ alert(alertMessage); }

// everything else seems okay, do rest of logic here
else{ // Do email stuff here //********* Page Redirect *********// var url = "/home/home.jsp"; window.location.href = url; //*******************************************// }

 

Vadim RudkovVadim Rudkov

There is also a possibility to create a workflow rule from Email Messages to update a parent case based on information contained in the email.