I have created object using javascript itself without using controller. It is done by using

var cas = new sforce.SObject("Case"); cas.Type = document.getElementById("Type").value; (mapping the value into the corresponding field var a = sforce.connection.create([cas]);

case is created when we use insdie salesforce. But when I publish this page in the sites , it is not working.. Please provide me a solution .. Thanks in advance !!


I think that is because when you are using public site, no SessionId is generated. You can verify this by Adding {!$Api.Session_ID} on a visualforce page which will print NULL.

Salesforce AJAX toolkit require a session-id to be generates for authentication & authorization of the the request.

If you want to create a case without session Id, you will have to create a controller or a public rest service.

Also you will have to provide the site user profile access to create cases.

If you want to go for rest service, here is a good article on that: Creating Public Rest Service.

There was one more detailed article that I read yesterday however I am not able to find the link, I will post the link when I find it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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