You need to sign in to do that
Don't have an account?
'INVALID_SESSION_ID', exceptionMessage:'Invalid Session ID found in SessionHeader: Illegal Session
Hi Forum members
I added a hoover to my visualforce page and the hoover appears on the mousover event of a label
onmouseover calls a javascript code which is following
<script src="/soap/ajax/15.0/connection.js"></script>
<script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
function myHover()
{
sforce.connection.sessionId = "{!$Api.Session_ID}
var resultQuery = " Select ID,Name from ACCOUNT LIMIT 2";
try
{
result = sforce.connection.query(resultQuery);
}
catch(e)
{
alert(e);
}
//Some Code to show hoover with result
}
Now the problem is this code works fine in a DEVELOPER Org and shows data of above query on hoover
But when i run this same code in sandbox or any Trial org
the line sforce.connection.query(resultQuery); raise following excepion
{faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', detail:{UnexpectedErrorFault:{exceptionCode:'INVALID_SESSION_ID', exceptionMessage:'Invalid Session ID found in SessionHeader: Illegal Session', }, }, }
Please comment if someone knows the solution of this problem
Thanks
I bet the session id is null when it calls the soforce.connection.query().
It is highly discouraged using the s-control code in a visualforce page. Try to use visualforce standard components such as <apex:actionfunction> or <apex:actionSupport> etc., to implement those.
But, to do your way correctly would be:
<apex:includeScript value="/soap/ajax/15.0/connection.js"/>
<script> function init() { sforce.connection.sessionId = '{!$Api.Session_ID}'; } function myHover()
{
...........
...........
} // main code var previousOnload = window.onload; window.onload = function() { if (previousOnload) { previousOnload; }
init(); } </script>
</apex:page>All Answers
I bet the session id is null when it calls the soforce.connection.query().
It is highly discouraged using the s-control code in a visualforce page. Try to use visualforce standard components such as <apex:actionfunction> or <apex:actionSupport> etc., to implement those.
But, to do your way correctly would be:
<apex:includeScript value="/soap/ajax/15.0/connection.js"/>
<script> function init() { sforce.connection.sessionId = '{!$Api.Session_ID}'; } function myHover()
{
...........
...........
} // main code var previousOnload = window.onload; window.onload = function() { if (previousOnload) { previousOnload; }
init(); } </script>
</apex:page>Hi Venkat
I used the same code as per your solution below, thanks for the solution
I still get the same error SF:INVALID_SESSION_ID:INVALID SESSION ID FOUND IN SESSIONHEADER:ILLEGAL SESSION
Here is my code
<apex:page controller="comFuzeqna">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
<script language="javascript">
function init() {
sforce.connection.sessionId = '{!$Api.Session_ID}';
var user = sforce.connection.getUserInfo().userName;
var temp=new Array();
temp=user.split('@');
alert(temp[0]);
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
hash ="34B64193-9129-4C91-92AB-7890777543CD"+ month+"/"+day+"/"+year+temp[0];
var hash1=hex_md5(hash);
alert(month + "/" + day + "/" + year);
alert(hash);
alert(hash1);
}
try{
var result=sforce.apex.execute("comFuzeqna","InternalSSO",
{auth:"hash1",username:"",firstname:"",lastname:"",email:"",specialPublic:"",specialPublic:"",draft:"",workIncidents:"",specialPrivate:"",groupName:""});
//document.getElementById('auth').innerHTML='user authcode is'+result;
alert(result);
}
catch(err){
alert(err);
}
var previousOnload = window.onload;
window.onload = function() {
if (previousOnload) {
previousOnload();
}
init();
}
</script>
<head >
</head>
<apex:form id="loginform" >
<body onload="init();" >
<p>current user name is:"{!$User.UserName}" </p>
<p>current user key is:"243bh324hj23j32bj32bnjnjn3jnn"</p>
<div><apex:commandButton value="Search KB" onclick="kbframe();"/><apex:inputText /></div>
<div></div>
<p><apex:outputText value="Search Results"></apex:outputText></p>
</body>
</apex:form>
</apex:page>
Did you ever resolve your error?
I am having a similar issue.
Since I am not originating my call from a visual force page the command '{!$Api.Session_ID}' does not work.
were you able to set the session without calling login again.
This post really helped me. Thanks a lot:)
Aka.ms/remoteconnect (https://akamsremoteconnect.info/)