Pages

Thursday, January 16, 2014

Salesforce: Accept Queue in Page Layout

A Queue can to support multiple object: Case, Lead and Custom object with list of users.

View
When a queue is created for an object, example Case, by default, a View will with the Queue name will be created in Case View. This View will filtered by owner of the Queue name. The View will be visible for All Internal Users.

Case assign to a queue will be shown in that View.

Accept Queue
By default, user in the Queue will see all Case owned by that Queue in the View. User would like to accept that Case just need to click Accept button in the View.

But, usually user need to go into the case detail before Accept the case, so it is not really user friendly if user have to go back to the View to Accept it. It would be nice and more efficient if user able to Accept case directly in the Case detail page.

By default, this is not possible, but with simple tweak, it is possible. Here you go:
  1. Create a custom button in Case object. Follow this step:
  2. Setup - Customize - Cases - Buttons, Links, and Actions
  3. Click 'New Button or Link', select 'Detail Page Button' in Display Type and Behavior select 'Execute JavaScript'
  4. Paste script below
  5. Add custom button created to the Case page layout.
  6. Done

The script:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var CaseObj = new sforce.SObject("Case"); 

var caseOwner = '{!Case.OwnerId}'; 
var caseOwner3 = caseOwner.substring(0,3); 
//window.alert(caseOwner3); 

if(caseOwner3=='00G') 

//window.alert("assign case to user"); 
CaseObj.Id = '{!Case.Id}'; 
CaseObj.OwnerId = '{!$User.Id}'; 

var result = sforce.connection.update([CaseObj]); 
location.reload(true); 

else 

//window.alert("just alert"); 
window.alert("This Case has been handled by someone else"); 
location.reload(true); 
}

This script will check if Case owner is not a Queue, it will not allow user to accept it.
You can enhance with different type to hide Accept button for Case not owned by Queue.

No comments:

Post a Comment

Page-level ad