Thursday, December 12, 2013

Salesforce: Close Case in one click

To close a Case in Salesforce, user need to have Edit permission on Case object. By default, when a user click Close Case button, user will be bring into a new page to enter information needed before close the case. Admin can set mandatory fields at the Close Case page, from Setup - Customize - Case - Page Layout and look for Case Close Page Layouts.

But, can we make this simple? Meaning just click a button to close an open case without have to open a new page. Yes, by using custom button. Here we go:
  1. Setup - Customize - CasesButtons, Links, and Actions
  2. Click New Button or Link, enter Label and Name, select Detail Page Button in Display Type and Behavior select Execute JavaScript
  3. Paste JavaScript script below
  4. Add custom button created to the page layout and remove default Close Case button, you can have multiple page layout with different button based on user profile and Case record type.
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
if ({!NOT(Case.IsClosed)}){
   caseObj.Status = 'Closed';
   var result = sforce.connection.update([caseObj]);
   if (result[0].success=='false') {
   } else {

Another option is to enable Closed value available in Case Status. By default, this value will be not available when user Create or Edit the Case, but we can enable it. Here we go: Setup - Customize - CasesSupport Settings, enable Show Closed Statuses in Case Status FieldThis will make Closed status available when user create or edit Case, user also will not bring into Case Close page any more.

In the same Case Support Setting page, admin also can hide Save & Close button by enable Hide Save & Close Button and Cls Links.

How about if I want to limit only certain profiles can close case?
Easy... create validation rule with this formula, sample:
RecordType.Name = 'CSD Case' && ISCHANGED(IsClosed) 

Read this document for more information on Closing Cases.

No comments:

Post a Comment

Page-level ad