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
Jason L.ax300Jason L.ax300 

s-control for closing a case

I want to create something to allow our support agents to quickly close cases that have the same case reason, resolution and time spent.  (things like information requests, uploading a file etc etc)  They spend about 10 minutes resolving minor, repetative support issues including fixing the issue, updating the case and sending the response to the client.
 
I'd like to be able to create a 'close - info request' custom button that invokes an s-control to do the following:
 
 - update 6 or 7 case fields (standard and custom)
 - close the case
 - add a standard comment
 - send solution or email to the case contact
 
Even updating the fields is a good start, just something to cut down the time they spend doing the same thing over and over.
 
I have a fairly good understanding of how I could use an s-control to do this, I just don't know where to get started.  I've added AJAX toolkit and made a simple control that adds an account (from the tutorial) but I'm not sure where to start developing my own control.
Jason L.ax300Jason L.ax300

hmmm, updating the fields seemed to be a lot easier than I thought.  The only problem I'm having now is how to get the record ID for the current case that is being viewed:

 

var c = new sforce.SObject("Case");
c.id = "{!Case.Id}";
c.Origin= "Web";
c.Type = "Other";
c.Problem_Area__c = "Product";
c.Problem_Sub_Area__c = "module";

var result = sforce.connection.update([c]);

If I hardcode the Case.ID, it works fine, but I'm not sure what the syntax is to get the record ID of the page you're currently viewing.

SteveBowerSteveBower
Just eyeballing, the capitalization is very persnikity because with Javascript you can create
c.id, c.ID, c.Id, c.iD and they are all different entities.

So, I think you're getting the case id correctly, you're just putting it in the wrong place.

Try c.Id  (uppercase "I") and see if that does the job?

Steve.

Jason L.ax300Jason L.ax300

yeah, that was it.  It works great now.  I haven't figured out the other stuff, but I think it's best to handle subsequent actions using workflow instead.

SeawardTSeawardT
Did you simple copy that code into an S-Control snippet and that worked for everything? Or are you still working on this?
Jason L.ax300Jason L.ax300
using that code in an S-control worked great.  We're using it right now for closing cases quickly based on certain criteria.
 
We created the s-control and then created a button that calls that s-control on the case view page.
SeawardTSeawardT
I am trying to do the same, but running into problems.

Is that the only code you used (above) or did you have supplementary code around it? And did you define it has a URL/HTML/Snippet?
Angel118Angel118
Hi ,
                I have a similar requirement where I need to close the Case via a Custom Button on the Case Layout.
I tried a S-Control but its taking me to the Case Close Layout..

Any Help is Appreciated...

Angel..
Jason L.ax300Jason L.ax300

here is the code I used in the control. This updates the case with hard-coded params, closes the case and then returns to the case view page for the case it just closed.

If you need to update additional fields, install the AJAX tools and use the Explorer to find the names of the database fields you need to update.

<!-- start -->

<html>
<!--
Generated by AJAX tools
Date : Thu Aug 30 2007 12:27:14 GMT-0400 (Eastern Daylight Time)
Template : simple.html by manoj@cheenath.com
SControl : Update_Case
-->
<head>
<script src="/soap/ajax/8.0/connection.js"></script>


</head>
<body>
<Script>

var c= new sforce.SObject("Case");
c.id = "{!Case.Id}";
c.Origin= "Internal";
c.Type = "Support";
c.Reason= "Infrastructure";
c.Case_Sub_Reason__c = "False Alert";
c.Status = "Closed";
c.Time_Spent__c = ".1";
c.Resolution__c = "False Alarm";

 

var result = sforce.connection.update([c]);

 

if (result[0].getBoolean("success")) {
var urltogo = "/" + "{!Case.Id}";
window.parent.location.href = urltogo;

} else {

alert("failed to update record" + result[0]);

}

</script>
</body>
</html>

 

<!-- end -->

Angel118Angel118
Thanks Jason,
                        But did u used this code to Close the case or just to update the values of the particular Case ?

I tried it in my Org, Its not closing the case though is updating the Case values very well...

Angel...
Jason L.ax300Jason L.ax300
yes, it closes the case for us as well.  Do you get any errors at all?
Angel118Angel118
Hi,
      Jason for me it not closing the case,
This is what i am putting in my code...

Code:
<script type="text/javascript" src="/soap/ajax/10.0/connection.js" > </script>
<script type="text/javascript" > 

alert("{!Case.Id} ");
var CaseDetails  = sforce.connection.query("select CaseNumber, IsClosed,Origin, Status from Case where Id = '{!Case.Id}'");
alert(CaseDetails);


var _Case =new sforce.SObject("Case");

_Case.Id ="{!Case.Id}";
_Case.status = "Closed";

var result  = sforce.connection.update([_Case]);
alert(result);

window.parent.location.href="https://na5.salesforce.com/500/o"; </script>

 

SteveBowerSteveBower

Again, just eyeballing, read my previous posting in this thread...

try _case.Status  instead of _case.status.

Best, Steve.
Angel118Angel118
Thanks a Ton Steve & Jason..

It worked fine now...


Angel...