You need to sign in to do that
Don't have an account?
sforce.connection.login giving errors in Sites
Hi I am using sforce.connection.login call from javascript in my VF page accessible from a Site that what is does is to log a user in Salesforce (the user exists in Salesforce and it is active), but I am getting the following error:
{faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }
here is my VF page:
<apex:page showheader="false" standardStylesheets="false"> <apex:includeScript value="/soap/ajax/17.0/connection.js"/> <apex:includeScript value="/soap/ajax/17.0/apex.js"/> <script type="text/javascript"> function approveCrf() { try{ sforce.connection.sessionId = '{!$Api.Session_ID}'; var username = document.getElementById('un'); var password = document.getElementById('pw'); var loginResult = sforce.connection.login(username.value, password.value); }catch(error) { if (error.faultcode.indexOf("INVALID_LOGIN") != -1) { alert("check your username and passwd, invalid login"); } else { alert(error); } } } </script> <form id="loginForm"> UserName: <input type="text" id="un" size="15" value=""/><br /> Password: <input type="password" id="pw" size="15" value=""/><br /> <p><input type="button" value="Login and Approve" onclick="approveCrf();"/></p> <apex:message styleClass="locationError" /> </form> </apex:page>
Any ideas?
Thanks
there is no session id for site access.
you need to use visualforce and apex for your queries.
and if you need authenticated access then you need to use the sites-portal integration
All Answers
there is no session id for site access.
you need to use visualforce and apex for your queries.
and if you need authenticated access then you need to use the sites-portal integration
Yes you can't login via javascript.
Site gives you unauthenticated access (read/create on standard objects, full access on custom objects)
But again this is unauthenticated access use full for web2any object flows or search and query public information or displaying public content.
If you need to authenticate users the only supported way is to integrate with customer or partner portal products
it's part of the ajax toolkit let's you login to salesforce via javascript.
Site access doesn't have a session id, so this is not supported for sites.
You might not need this since sites already gives you the access you might need. take a look a these two articles:
An Introduction To Force.com Sites
Authenticating Users on Force.com Sites
Hi,
I know this is an old discussion, if someone has the same issue and because I had the same..
This was probably caused by the fact that your site uses a site prefix (such as abcd.force.com/prefix).
In this case, you just need to set the serverUrl variable which is a property of the connection object in the ajax toolkit.
Here is the example I used (api 22.0) :
hope this will help..
Adrian
I am facing the same issue where using sforce calls i am trying to insert attachments from sites to salesforce but getting sesion Id invalid error.