+ Start a Discussion
EdgeLineEdgeLine 

Query Salesforce in ajax outside of Salesforce?

Ajax seems to be implemented on an html page that is called within the salesforce system upon clicking a custom link.
 
But, is it possible launch a web page outside of salesforce and still reference the objects and retrieve information via the queries?
 
If so, it would appear one would need to adjust this line of code:
 
sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_70}", true);
 
Can anyone tell me if this is possible...?
 
Thanks
Edgeline
michaelforcemichaelforce
Yes, the AJAX toolkit allows you to use everything the API offers... from what I understand.  To call the API from an html (javascript) page outside of salesforce.com you simply have to login first, like so:
 

var loginResult = sforceClient.login(“username@somedomain.com”, “secret”);

 

loginResult will then hold the usual returns... sessionid, serverurl, etc.

 

-Hope this helps

michaelforcemichaelforce
Just read one more thing that is good to know...  apparently if your browser security settings are too high you will have trouble doing this.  You must allow "accessing data sources across domains".
EdgeLineEdgeLine
Thanks Michael.   I actually got a 'security alert box' asking for confirmation to download. Upon clicking yes the code worked. But I found a more clearer way to represent the task of extracting salesforce data into a web browser via ajax outside of salesforce:Code:
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

 

<script language="javascript">

<!--

window.setTimeout(";", 1000);

sforceClient.init(null, null, false)

var loginResult=sforceClient.login("username", "password")

document.write (loginResult);


</script>

 
I am would love to be able to do this in .NET and pull  (e.g. all the names of current opportunities) into a .NET grid control on the fly without having to mess around with code. But, alas there don't seem to any examples from start to finish which show this basic task.
I messed around with the wsdl and 'login result' example in .NET but cannot get any further additional information into the grid.