Skip to main content
edited title
Link
Santanu Boral
  • 36.2k
  • 8
  • 45
  • 72

Case Details Javascript Custom Button using JavaScript - Take Ownership

remove salesforce crm tag
Link
Dave Humm
  • 5.1k
  • 5
  • 25
  • 38
Source Link
Paul
  • 71
  • 1
  • 10

Custom Button using JavaScript -

I have a custom button called "Take Case" on the Case object. The "Take Case" button is used when a specific case is assigned to a queue and a member within that queue presses the button to take ownership of the case. How can I throw an error that says "You cannot take this case because you are not part of the queue" if someone outside of the queue presses the "Take Case" button?

This is what I have so far:

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

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
caseObj.OwnerId = '{!$User.Id}'; 
caseObj.Status = 'Working';
caseObj.Assign_to_Queue__c = 'False'; 
var result = sforce.connection.update([caseObj]); 

if (result[0].success=='false') { 
alert(result[0].errors.message); 
} else { 
location.reload(true); 
}