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
VickiVicki 

Help with first S-Control

I am editing an  S-control for quickly closing a Case, eliminating the steps to change status to closed and then clicking Save again.  This part of the s-control works.  However, we need to auto send a notification to the Contact for the Case.  The problem is that if there is no Contact populated on the Case (which happens many times, not all Cases require a Contact), the s-control gives an error for missing Contact, and the user has to click the Save again.  I am trying to avoid the additional Save and want the s-control to loop thru one code if Contact is null, and another if populated, this allows the s-control to use IsNotifyContact=1 or 0 depending on the loop. 
I am not setting up the If-Then part of the s-control correctly, any help debugging this would be tremendously helpful, here's the s-control I've edited:
 
 
 
<!-- 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();
var Contact = {!Case.ContactId};

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

<!-- end code -->
Ron HessRon Hess
i think you are close, try this

var Contact = "{!Case.ContactId}";

if (Contact == "" )


note the quotes around the merge field, and the use of  "==" to compare strings.




VickiVicki

Thanks, that helped, I see it's passing the Contact value thru now, but I still can't get it to run.

I probably need some sort of editor in order to debug it, the basic s-control works, until I added the "IF" part, now it won't work at all, maybe I put it in the wrong part of the code.  I'll try to think of another way to make isnotify=0 if Contact is blank, I thought this would have worked.

Thanks for looking at this and replying, I will keep trying.....