4

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

2 Answers 2

3

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.

3
  • 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
    Commented Jan 15, 2013 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
    Commented Jan 15, 2013 at 15:46
  • @joshbirk: thanks, that is a good idea. I was also considering iframes as an option.
    – Sai
    Commented Jan 15, 2013 at 15:48
0

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.

1
  • yes, it has access to user object and there is no VF involved
    – Sai
    Commented Jan 14, 2013 at 23:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .