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
John L.ax1429John L.ax1429 

Creating a custom case accept button for cases

 

Can someone develop a new button or show me how to do this.  I am trying to create a custom button on cases to click if they want to accept the case.  Which would only change the ownership and status of the case from new to working.  If anyone can assist me with this I would be very appreciated.  Thank you for the help in advance.

 

 

John

TrimbleAgTrimbleAg

{!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 {
window.parent.location.href="/{!Case.Id}/e?retURL=%2F{!Case.Id}";
}

 

Display type = Detail Page Button

Behavior = Execute JavaScript

 

This will auto assin the user to the case and take them to the edit screen.

HariDineshHariDinesh
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 

caseObj.Status = ' Working'; 

var result = sforce.connection.update([caseObj]); 
window.location.reload();

Display Type:      Detail page Button

Behaviour:           Execute Javascript

Content source :Onclick Javascript

John L.ax1429John L.ax1429

This doesnt change the owner to the user that clicked the button. but it does change the status of case.

HariDineshHariDinesh

Hi,

 

Yes, this does happen with above code.

I just gave a sample code which you might need to update/upgrade as per your requirement.

 

I think by adding below simple statement you will get what you are looking for...

 

caseObj.OwnerId = '{!$User.Id}'; 

 

complete code will look like

 

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
caseObj.OwnerId = '{!$User.Id}'; 

caseObj.Status = ' Working'; 

var result = sforce.connection.update([caseObj]); 
window.location.reload();

 

 

 

KattyKatty
Hi, I need the same scenario in Lightning. Here in my status once I click on accept button my status should be changed from "New" to "Open". I have this on classic Which will not work in lightning. Can some one help me?
KattyKatty
It is on priority for me, Please help me. Thanks in advance.