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
JLBJLB 

faultcode:'sf:Invalid_session_id' error in custom component inside visul force page

Hi -

 

I am getting an error when clicking a custom javascript button from a related list on Case in the service console, but only in Internet Explorer (8). Chrome works fine.

 

The error is: faultstring"INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session"

 

The button is:

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}
{!REQUIRESCRIPT("/support/console/27.0/integration.js")} //Chrome worked without this, not sure if it is doing anything now
{!REQUIRESCRIPT("/soap/ajax/27.0/apex.js")}

var profile = "{!$Profile.Name}";
var LockedBy = "{!Case.Locked_ById__c}";
var CompletedBy = "{!Target__c.Completed_By__c}";
var Now = new Date();
var t = new sforce.SObject("Target__c");
t.id = "{!Target__c.Id}";

if(profile.search("Service")>=0 || profile.search("System Administrator")>=0) {
	if("{!Case.Locked_ById__c}" == "{!$User.Id}") {
		if(CompletedBy=="") {
			t.Completed_By__c = "{!$User.Id}";
			t.Date_Completed__c = Now;
                        sforce.connection.init('{!$Api.Session_ID}', 'https://ap1.salesforce.com/services/Soap/u/27.0'); // have tried several things in here. Chrome works fine without this line at all.
			result = sforce.connection.update([t]);
			location.reload();
//and so on...

 I have made many attempts at solving this with no luck so far.

 

Thanks in advance for any assistance,

JLB

S ShawS Shaw

HI JLB,

 

How I can understand this is, accessing Salesforce Content throug Javascript is same like using Force.com API. When we are making API call, we need to first login and then we get access to the salesforce instance.

 

You can try the below code to Login through Javascript:

 

function Login()
{
  try
    {
	var result = sforce.connection.login("<UserName>", "<password> + <Security Token>");
    } 
  catch(error) 
    {
    }
}

 Once you login, you can access.

 

JLBJLB

This is a button sitting in a related list on a case screen.

 

  1. There is no way (thankfully) to get the username and password of the user who clicked it and
  2. If what you said was true, it wouldn't work in ANY browser. It currently functions in Chrome.
PandaDevPandaDev
Hi,

We have the same problem for several months already. It occurs seldom when users click on the "submit for approval" custom button at opportunities. It works fine with Chrome and Firefox but sometimes it doesn't work with Internet Explorer. It is a browser issue as the same opportunity works fine with Chrome or Firefox. 
Pd: We have the latest IE versión (11) with all security patches installed

Any help on this issue would be greatly appreciated.

Best regards,