+ Start a Discussion
DrawloopDrawloop 

Invalid Session ID when using JavaScript to open a URL and create object using API

I'm using JavaScript to do some Salesforce field updates then open a URL in the same window with a side bar. The following is the last line of JavaScript that calls the button which calls an s-control:
 
location.href="/servlet/servlet.Integration?scontrolCaching=1&lid=00b00000006onut&eid=a02000000007USx";

 The lid is the button and the eid is the custom object that the button is being called from. The button opens a link to our service inside the existing window with a sidebar. (The only reason I'm calling this button inside the JavaScript is that I don't know a way to open the URL in this same manner.) Our service tries to create a Salesforce object using the session id of the user as the creator of the object. It is at this point that we get the 'Invalid Session Id - session id has timed out' error. I've logged in as two different users and the session id is the same and I don't think it should be. My guess is that the above link was created specific to that session id, but I don't see how that's possible.
 
Any thoughts on how to fix or get around this? Much appreciated.

DrawloopDrawloop
Ok. I fixed this by passing the user session id in the URL of the button.
ImaghrooriImaghroori
I am running into the exact same issue. Could you please post your final solution?
DrawloopDrawloop
I just added the merge fields {!API.Session_ID} and {!API.Partner_Server_URL_70} as parameters to the URL that I was redirecting to.