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
thecrmninjathecrmninja 

Bypassing the standard Case Closure workflow

We would like to remove the ability for anyone to uncheck the 'Notify contact on Case Close' box on the Case Closure. I searched but there doesn't seem to be a way to make this a 'read-only' field, so the workaround I came up with was to go to Support Settings, then add Closed to the Status field on Case Details page, and then remove the Close Case button. This way, the user will never see the Case Closed page and thus will not be able to uncheck the 'Notify contact on Case Close' box.

However, the problem now is: when I set the Status to Closed, it doesn't trigger the email to Contact. Does anyone know how to trigger the email to go out EVERYTIME a Case is set to Closed status? Thanks much!

Best Answer chosen by Admin (Salesforce Developers) 
thecrmninjathecrmninja

To achieve something similar, I just created the following scontrol

 

 

<!-- begin code -->
<!-- replace 'Closed' (without quotes) in the code below with the Status desired for case closure -->

<html>
<head>
<script src="/soap/ajax/8.0/connection.js"></script>
<script src="/desktop/desktopApi.js"></script>

<script>
function init() {

var desktop = new DesktopApi();
if (desktop.desktopPageWindow)
{
window.parent.location.href = "/{!Case.Id}/s?save=1&notifyContact=0&cas7=Closed&isdtp=mn&nooverride=1&retURL=/{!Case.Id}";
} else {
window.parent.location.href = "/{!Case.Id}/s?save=1&notifyContact=0&cas7=Closed&nooverride=1&retURL=/{!Case.Id}";
}
}
</script>
</head>
<body onload="init()">
<p>&nbsp;</p>
</body>
</html>

<!-- end code -->

 Then I referenced that scontrol in a Custom Button that I&nbsp;used to replace the Standard Case 'Close Case' button.

 

All Answers

thecrmninjathecrmninja

To achieve something similar, I just created the following scontrol

 

 

<!-- begin code -->
<!-- replace 'Closed' (without quotes) in the code below with the Status desired for case closure -->

<html>
<head>
<script src="/soap/ajax/8.0/connection.js"></script>
<script src="/desktop/desktopApi.js"></script>

<script>
function init() {

var desktop = new DesktopApi();
if (desktop.desktopPageWindow)
{
window.parent.location.href = "/{!Case.Id}/s?save=1&notifyContact=0&cas7=Closed&isdtp=mn&nooverride=1&retURL=/{!Case.Id}";
} else {
window.parent.location.href = "/{!Case.Id}/s?save=1&notifyContact=0&cas7=Closed&nooverride=1&retURL=/{!Case.Id}";
}
}
</script>
</head>
<body onload="init()">
<p>&nbsp;</p>
</body>
</html>

<!-- end code -->

 Then I referenced that scontrol in a Custom Button that I&nbsp;used to replace the Standard Case 'Close Case' button.

 

This was selected as the best answer
alvatsealvatse

Works beautifully! The only thing I needed to change for it to send the Notify customer email out is to change notifyContact from =0 to =1. Thanks again!

thecrmninjathecrmninja

VERY glad to hear it!  Thank you for confirming that it solved your issue.

*werewolf**werewolf*

That's a little sketchy URL hack there.  Why not just make a workflow that triggers on case closed that sends the email instead?  That seems more sustainable and requires neither code nor a custom button.

Andy BonesAndy Bones

I am very interested in this S-control.  Is there a Visualforce equivalent??

 

"S-controls have been superseded by Visualforce pages. After March 2010 organizations that have never created s-controls, as well as new organizations, will not be allowed to create them. Existing s-controls will remain unaffected."

 

~Andy.

thecrmninjathecrmninja

Werewolf has a very straightforward (and much more elegant approach) if you are chiefly concerned about always getting an email out (ALTHOUGH, such an approach would create a potential for duplicate emails if a user checks the 'notify' box).

 

You could also create a custom button and play around with the standard action functions (i've not tried this but you could probably get a solution there - just select "$action" from "select field type" and use some option like "{!$Action.Case.Close_Case}" (I've not used this for Cases, so I can't give you more direction than that).

 

You could also play with java scripting as this is an option on a custom button, though I also have no experience with that.

 

finally, you could create a custom button that points to a Visualforce page (change "Content Source" to "Visualforce Page", the controller associated with that page would then do two things 1) change the Case to "Closed" and 2) redirect the user back to the static Case page.  and, yet again, I have no experience doing this so you have a wonderful opportunity to show how much more of a ninja you are compared to me (or, maybe, you a samurai :-o  )

Andy BonesAndy Bones

Hmm,  so while testing... I was able to create the S-control AND it closes my case with 1-click.

Is there a way to loop in a second field value at the same time?

 

Possibly loop in a second line of code that will, in addition to marking "Status" to "Closed", make "Case Reason" be "X" picklist value??

 

I am not so interested in the emailing part.  My use for this is to bypass the Close Case form to quickly close duplicate cases.

 

Andy.

 

 

*werewolf**werewolf*

Well if you're just looking for a 1-click close then use the Quick Case Close Button.  Plus it's easy to add additional fields in using that.

thecrmninjathecrmninja

Well, given your business case, I would consider taking one of the following approaches...

 

option 1

**NOTE** - This approach assumes any user can identify cases as duplicates (and you don't have some review board process)

1) Create a custom field on Cases that is something like "potential duplicate" (checkbox)

2) Generate a " Before Update" trigger on the Case object that reacts to the potential duplicate box being checked and status not yet equaling close, have the trigger set status to closed



option 2

**NOTE** - This approach assumes there is a way for Apex to easily identify duplicate cases OR you have a process where only certain users can make dupe determinations

 

1) Create a custom field on Cases that is something like "potential duplicate" (picklist that is hidden from users that shouldn't have the ability to determine if a case is dupe)

2) Generate a "Before Insert / Before Update" trigger that evaluates cases where potential duplicate is not set to some value (unreviewed?) and, if a Case appears to be a duplicate (and is not closed) sets the value in the picklist field

3) Then, create a list button for "Dupe Close" and generate a list that shows cases that are not closed and have the potential duplicate field set to the unreviewed value

4) You would probably also want to create button to set that potential duplicate field to "not a dupe" or some similar value

 

I only suggest this because it appears that there may be a more direct means towards meeting your objective (the button seems unnecessary altogether in this use case)

 

good luck

 

thanks werewolf for the boss custom button!

 

thecrmninjathecrmninja

and, now that i read my post, you could revise option 2 to use the trigger in option one in option two as well.  You would then just create a custom button (for a list instead of a detail page) that changes the value in the potential duplicate field to whatever value will cause the trigger to close the case

 

Then, you can look through a list of cases, check the actual dupes and close them en masse.

 

here is an example of a mass update javascript for a list button on cases.....

 

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

var records = {!GETRECORDIDS( $ObjectType.Case )};

if (records[0] == null) {
alert("Please select at least one record.") }
else {

var errors = [];
var result = sforce.connection.deleteIds(records);
if (result && result.length){
var numFailed = 0;
var numSucceeded = 0;
for (var i = 0; i < result.length; i++){
var res = result[i];
if (res && res.success == 'true'){
numSucceeded++;
} else {
var es = res.getArray("errors");
if (es.length > 0) {
errors.push(es[0].message);
}
numFailed++;
}
}
if (numFailed > 0){
alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n"));
} else {
alert("Number of records deleted: " + numSucceeded);
}
}
window.location.reload();
}

Andy BonesAndy Bones

Neat!  Thanks for the suggestions!

 

I was playing with a custom field (formula) with this code:

 

HYPERLINK( "/" + Id + "/e?save=1&notifyContact=0&cas7=Closed - Duplicate&nooverride=1&retURL=/" + Id, "Duplicate Close", "_self")

 

This creates a quick link in the field called "Duplicate Close" and when pressed, sets the "Status" to "Closed - Duplicate"

 

I THINK this will work for me... can you guys see any reason this could be bad?

 

~Andy.