+ Start a Discussion
jjuezjjuez 

Closed case + condition must have a solution

Hi all,
 
I would like to be able to force users to have a solution linked to a case before they can close the case. Salesforce provides the following code, which works great:
Code:
<html>
<head>
<script src="/soap/ajax/13.0/connection.js">
</script>
<script>
function init()
{
var queryResult = sforce.connection.query("Select count() from CaseSolution Where CaseId = '{!Case.Id}'");
var size = queryResult.size;
if (size > 0) {
//go to the standard case close page without invoking the override
window.parent.location.href = "{!URLFOR($Action.Case.CloseCase, Case.Id, [retURL=URLFOR($Action.Case.View, Case.Id)], true)}"
}
else {
alert("Case must contain at least one solution before it can be closed.");
//go to the standard case detail page
this.parent.location.href = "{!URLFOR($Action.Case.View, Case.Id)}";
}
}
</script>
</head>
<body onload="init()">
<p>&nbsp;</p>
</body>
</html>

I need to extend this code to force it only when:
there is no solution linked to the case, and 2 specific values are selected in 2 different case picklist fields.
I have tried different things but nothing works.
 
Does anyone know? Thank you very much
Julian
knicholsknichols
Just query the two fields after you check the count to see what they are.  Then you can check their values before going through the rest of the logic.
LdynesLdynes

Hi,

I was so happy to find this code, but have no idea where to use it. Is it an s-control or what? Can anyone help?

Thank you-

Lisa

jjuezjjuez

Lisa,

1. Create a new S-Control, Type = HTML, and just copy/paste the code

2. Override the "Close Case" button with your S-Control

 

 

However, I am still not able to add one extra condition (which is the value of a picklist field). I always get "error on page" messages when clicking on the button.

Anyone who can help me??

 

Thank you

knicholsknichols
Hi, can you post your code?  I'll see if I can help.