Custom Button to take Ownership for Case Record


Create a new Detail Button on the Case object.
Set Behavior to Execute JavaScript and Content Source to OnClick JavaScript
Paste the Below snippet of code in the window 

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

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
caseObj.OwnerId = '{!$User.Id}'; 
var result = sforce.connection.update([caseObj]); 
if (result[0].success=='false') { 
alert(result[0].errors.message); 

else { 
href= "https://cs16.salesforce.com/ui/support/servicedesk/ServiceDeskPage#/{!Case.Id}" ;  // return to console
document.location.reload(true)               // Refresh the Tab
}

Note : Change the return URL   to Current URL.

Enjoy Coding !!

Comments

Popular posts from this blog

Test-Driven Development in Salesforce

Setting a default 'From' address when sending an email from Cases

Email Messaging from Salesforce