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
AkaedingAkaeding 

Custom Case Buttom

I already created the button called "Take Case"

 

It was requested to do 2 things:

 

  1. Assign the current user who clicked on it as the "Case Owner" - I figured this part out.
  2. Take the current user to the edit page for the case record. - I'm stuck on this.

 

It is a detail page button, that is executing javascript on click. 

 

Any ideas how I can get it to open the case edit screen?
Best Answer chosen by Admin (Salesforce Developers) 
mpannmpann

Try this:

 

window.parent.location.href="/{!Case.Id}/e?retURL=%2F'{!Case.Id}'";

 

you can quote code by using the Code formatter in the tool bar :)

Message Edited by mpann on 09-04-2009 01:07 PM

All Answers

mpannmpann

Could you just use this URL?

 

/{!Case.Id}/e?retURL=%2F{!Case.Id}

 

 

AkaedingAkaeding

I think that's probably pretty close...I got this error text when clicking the button:


A problem with the OnClick JavaScript for this button or link was encountered:

invalid flag after regular expression

 


invalid Flag? 

 

 

I am ubernoob...so that means very little to me as far as being able to see the problem in my code.

 

mpannmpann
Could you post the code of your s-control?
AkaedingAkaeding

Here it is:

 

{!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 {
       /{!Case.Id}/e?retURL=%2F'{!Case.Id}'
    }

AkaedingAkaeding
eww...I can't disable smileys?...pfft
mpannmpann

Try this:

 

window.parent.location.href="/{!Case.Id}/e?retURL=%2F'{!Case.Id}'";

 

you can quote code by using the Code formatter in the tool bar :)

Message Edited by mpann on 09-04-2009 01:07 PM
This was selected as the best answer
AkaedingAkaeding

Ahh!

 

I see it now!

 

Thanks so much for the help!  My new "Take Case" button is in place and doing exactly what it was intended to do:

 

1. Change the Case Owner to the user that clicks the button

2. Open the Case edit screen, after assigning ownership.

 

Code Below if anyone wants a "Take Case" button (using the Paste Code button...Thanks again, mpann!):

 

This is a "Detail Page" button, "execute Javascript" is the behavior, and the content source is "onclick javascript":

 

 

{!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}"; }