Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 

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 https://mysite.com/pkb/services/Soap/u/25.0 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

thanks

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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

share|improve this answer
2  
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
add comment

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
add comment

Your Answer

 
discard

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.