Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example, i have a simple JS button which returns the username of the logged in user.


var name= sforce.connection.getUserInfo(); 
alert( name.userName);

This works perfectly fine when in salesforce but, returns an error when clicked from Customer Portal. Am i missing something?

Usecase is that i am trying to get some CP user details to display on an HTML area. Any thoughts?

Update: I got the button to work (changed it to v25.0 from 20.0- my bad) but the same JS in cpheader or HTML sidebar component gives below message :(

Error: enter image description here

Refused to set unsafe header "User-Agent" POST 500 (Internal Server Error) connection.js:599 Uncaught {faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', detail:{UnexpectedErrorFault:{exceptionCode:'INVALID_SESSION_ID', exceptionMessage:'Invalid Session ID found in SessionHeader: Illegal Session', }, }, } connection.js:1019


share|improve this question
up vote 3 down vote accepted

From the example above it looks like you are using Sites with Customer Portal (based on the custom domain). The AJAX toolkit is not currently supported in Sites.

share|improve this answer
Right, it is trying to use the SOAP endpoints. You can use JavaScript Remoting, however, which is supported and can handle AJAX style pages. – joshbirk Jan 15 '13 at 0:16
@Ryan: that is correct. And just out of curiosity, would it have worked if it was "out of box" customer portal without sites? – Sai Jan 15 '13 at 15:46
@joshbirk: thanks, that is a good idea. I was also considering iframes as an option. – Sai Jan 15 '13 at 15:48

What is the error? There's more than a good chance that you're just running into a security issue. Check out Customer Portal User Profile and make sure that it's got the correct level of access to objects, and of course, to your Apex/VF.

share|improve this answer
yes, it has access to user object and there is no VF involved – Sai Jan 14 '13 at 23:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.