+ Start a Discussion

Problem with an S-Control which is intended to perform a case search

I want to have a search field on the SalesForce home page (home tab) where one can enter a case number and after clicking on Search-button being redirected to this case. However something in the following code is wrong, the variable "ident" don't take the CaseID but something else. And I'm also not sure if the URL -creation statement is correct.
    <script src="/soap/ajax/10.0/connection.js"></script>
    <script language="JavaScript">

        function findCase(number) 
        var ident = sforce.connection.query("Select Id from Case where CaseNumber  = '" + name + "' limit 1");
        window.parent.location.href = "https://emea.salesforce.com/{ident}";
        return false;
    <FORM NAME="myform" onSubmit="return findCase(this)">
        Enter Case Number: <BR>
        <INPUT TYPE="text" NAME="inputbox" size=10 VALUE=""/>
        <INPUT TYPE="SUBMIT" NAME="button" Value="Search Case"/><br>

The other problem would be the integration of this S-Control in the home tab. If I enter this code in setup->customize->home->home page components->new, the script will be removed after save. But apparently it will work through a frame
<IFRAME src="/servlet/servlet.Integration—lid=xxxxxxxxxxxxxxx&amp;ic=1" 
frameBorder=0 width="100%" height=150></IFRAME>

 with xxxxxxxxxxxxxxx being the S-Control ID. However in this case the found case will be displayed in the frame, while it should be displayed in the standard view (or even better in a new register tab). Can this be solved?


Message Edited by FGNY on 11-07-2007 09:10 AM

I would use the 'top' object to make sure the window is redirected instead of the frame.  Also, I would refer to the AJAX toolkit documents on the proper querying procedure.  ident will be a query result object from which you must pull the records array.  It would go something like so:


var ident = sforce.connection.query("Select Id from Case where CaseNumber  = '" + name + "' limit 1");
var irecords = ident.getArray("records");
top.window.location="/" + irecords[0].Id;

Thanks, it works now