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
sslatersslater 

INVALID_SESSION_ID Just started getting it.

Sometime in the past week I had an scontrol stop working with the infamous invalid session id. So I made a test and hoping someone here knows what it's about:

 

test.page:

 

<apex:page >
<h1>Congratulations</h1>
This is your new Page
<apex:scontrol controlName="test" width="1" height="1" rendered="true" />
</apex:page>

 


 

test.scf:

 

<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
<script>
try {
var tt = new sforce.SObject("Lead");
tt.Lastname = "test";
tt.Company = "test";

var result = sforce.connection.create([tt]);
}catch(error){
alert("Got error: " + error);
}
</script>

 


When I load this page, I get:

 

 

INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session

 

Any idea how to make this work?

 

Thanks!

bestjamiebestjamie

when you initialize the page , add following code

sforce.connection.sessionId = '{!$Api.Session_ID}';