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
Luke@TWSLuke@TWS 

Using AJAX in sidebar on Visual Force page

I have a sidebar component which gets some data from a custom object. Works fine on normal pages but I get an "Invalid Session ID found in SessionHeader: Illegal Session" error from the component when it loads up on a visual force page.

Any ideas?
werewolfwerewolf
I believe there's a merge field you need to use in your Scontrol to get it to get the proper session on a Visualforce page (the problem is that the Visualforce page is in a separate domain and so does not detect your SID cookie which is from naX.salesforce.com).  It's something to the effect of {!API.SessionId} (but that may not be it verbatim so look it up in the docs).
Luke@TWSLuke@TWS
Thanks for the reply. {!$Api.Session_ID} looks like the merge field I need but it seems sidebar components only take HTML and JavaScript. At the moment I have a little bit of HTML and I'm calling a JavaScript document but Salesforce won't resolve merge fields in any of these.
werewolfwerewolf
Put your Scontrol or Visualforce page in an Iframe on that home page component -- don't try to use the merge fields directly in it.