You need to sign in to do that
Don't have an account?
ccracy
Invalid_Session_Id returned while invoking an SControl from the UI
I have writen an HTML SControl that has a javascript function with an SOQL to query a custom object. SControl has a button that invokes this javascript function on click. I have added this Scontrol as a Home Page component. When I click this button, I get an exception saying Invalid Session Id. What can be wrong here?? Please advice.
Thanks,
Rohit M.
Thanks,
Rohit M.
The most recent versions of the Ajax toolkit don't require that you set a session id. The previous 3.3Beta toolkit did. Use the latest version if you're not already.
Best, Steve
Also, please let me know the way to set the session id.
Attaching the code for reference.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script language="javascript">
function getServerRecords()
{
var query = "Select Id From Contact";
var queryResult;
try
{
queryResult = sforce.connection.query(query);
}
catch(err)
{
alert("Error querying for Contact: " + err);
}
}
</script>
</head>
<body>
<input type="button" class="button" name="testButton" id="testButton" value="Test" onclick="getServerRecords();">
</body>
</html>
Thanks,
Rohit M.
Firefox
The Firebug add-on
easiest to just throw "debugger;" into your code as the first executable like of code in the function.
In addition to doing the query in a try/catch block you should check the results of the query. queryResult.success , etc.
-Steve
On clicking the button on the SControl, I get the following alert message:
falutcode: 'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', .....
You were mentioning about the way to include the session id in the older versions. Could you please let me know how could I explicitly include the Session ID while invoking the SControl?
This is really strange behaviour. I have writen many SControls, but never never faced this before.
Can someone please help whats wrong here??
For the current versions (which is what you're using), Salesforce inserts a currently valid session id into the generated HTML. If you do a "View Source" on the HTML of your simple page when it is rendered, you should see the session id that's being used.
Is the message being supplied from Salesforce code, or from your catch statement?
Sorry, I'm at a loss.
Check security changes, account changes, etc. but, if you're logged in, I think you should be getting valid sesion id's. Log out, take a walk, log in again and re-try. If that's doesn't work, call Salesforce and ask them to hit Ctrl-Alt-Delete and re-boot the entire system. :-)
When you figure it out, I'm curious what it is. Probably something trivial we've both overlooked :-)
Best, Steve.
-S
But, the way I have deployed the SControl is little different.
This is what has been done:
1. I have created an HTML SControl. It has a button. Onclik of the button I invoke a javascript function. This function has a SOQL query to get the Contacts.
2. Next I created a Home Page Component of type HTML Area. This is basically an IFrame with its src set to the SControl.
<IFRAME style="WIDTH: 50px; HEIGHT: 50px" src="/servlet/servlet.Integration?lid=01NT0000000Ch3T" frameBorder=0></IFRAME>
3. Next, I included this Home Page Component in the Home Page Layout. Son, now I can see the Button (defined in the SControl) on the Left Narrow panel of Salesforce.
Now when I click the Button, I get INVALID_SESSION_ID exception. Does this give any other clue??
Thanks,
Rohit M.
However, the right way to do this isn't to try to figure out how to pass the session id down through the Iframe to the s-control, but rather to do it differently in the first place.
Why are you using the Iframe intermediary? Why not just use a Custom Link for now? I realize that you may be doing this just to get a Button on the left hand side instead of a Link, but may I suggest that until (and if) Salesforce enables the same "Buttons and Links" functionality that they have on other object in home page components, just live with the link.
Since you could write the S-control to take the Session Id from the Request URL if it were passed in, then you'd be tempted to find a way to do a :
sort of thing. However, since the HTML you put in your html area is simply rendered, not processed first, you can't use any of the substitutions you'd like to pass on the URL for the S-control. You're sort of stuck.
So, I don't have an answer for you, although I see what you're trying to do and your error message is easily repeatable.
Best of luck, I hope this helps. Steve.
The problem is the iframe URL, you have to include &ic=1 at the end. Here's a working iframe link that displays an s-control on the left-hand side of the home page (on the nav bar). It also works on the wide right-hand side of the home page.
<IFRAME src="/servlet/servlet.Integration?lid=01N700000009DPd&ic=1" frameBorder=0 width=180> </IFRAME>
Note: &ic=1 will be translated to &ic=1 (this is ok, and will work)
jt_at_appirio.com