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
renurenu 

sf:INVALID_SESSION_ID

working fine before. But when i migrated to the latest AJAX API version it is killing me. I marked the code red here is the error
This is the error i am getting in the debug log window.
 
Using bookmarklet version of shell: commands will run in opener's context.
sf:INVALID_SESSION_ID
INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
 
Plz see the code below
I am using this ApI
 
<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>
 
window.setTimeout(";", 1000);
var date = new Date();
var task= new sforce.SObject("Task");
task.set("Subject", reason);
task.set("Type", "Other");
task.set("LegacyID__c", "SB");
task.set("WhoId", "{!Contact.Id}");
task.set("WhatId", "{!Account.Id}");
task.set("Status", "Completed");
task.set("IsClosed", "true");
task.set("ActivityDate", date);
task.set("Description", notes);

var saveResultTask = sforce.connection.create([task]);
for (var i=0; i<saveResultTask .length; i++)
{
if (saveResultTask [i].success == true)
{
}
else
{
alert("An error has occurred: " + saveResultTask [i].errors[0].message);
}
}
changeOwner();
parent.frames.location.replace("/servlet/servlet.FileDownload?file=0153000000042gA");
}
catch(error)

sforce.debug.log(error.faultcode);
sforce.debug.log(error.faultstring);
document.getElementById("divSave").style.visibility='hidden'
document.getElementById("Submit1").disabled = false;
return false;
}
Best Answer chosen by Admin (Salesforce Developers) 
The KnightThe Knight
Me too facing the same problem. I am using sforce.comnnection.create(mycustomobject). Some times the records are getting inserted but sometimes I am getting this error. Can anyone tell why this error comes.

All Answers

NaishadhNaishadh
i think you need apex.js and function.js file also.
e.g
<script type="text/javascript" src="/soap/ajax/13.0/apex.js">
<script src="/static/013008/js/functions.js" type="text/javascript">
The KnightThe Knight
Me too facing the same problem. I am using sforce.comnnection.create(mycustomobject). Some times the records are getting inserted but sometimes I am getting this error. Can anyone tell why this error comes.
This was selected as the best answer