function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
M.M. 

javascript - logging in with javascript and retrieving data

Hello once again... I've been trying to get some information from salesforce fields...

I've created a javascript that allows me to access the solutions table and access its fields...

this works well in a s-control... now, what I want is to access it from a external website... I know that, in order to do that, i'll need the login and password, but i don't know how to make that connection... can anyone help me? here goes the code sample...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<script language="javascript" src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

<script>

<!--

function initPage()
{
sforceClient.registerInitCallback(setup);

sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", true);
}

//Use this function as the entry point for your DHTML and JAVASCRIPT processing

function setup()
{
var queryResult = sforceClient.query("Select Id, Status, SolutionNote From Solution", layoutResults);

}

function layoutResults(queryResult)
{

if (queryResult.className == "Fault")
{
alert("There was an error: " + queryResult.toString());

}

else
{
if (queryResult.size > 0)
{

var output = "";

for (var i=0;i<queryResult.records.length;i++)
{

var dynaBean = queryResult.records[i];

output += dynaBean.get("Id") + " " + dynaBean.get("Status") +" "+ dynaBean.get("SolutionNote") +"<br>";

}

var textNode = document.createTextNode(output);

document.getElementById("output").innerHTML = output;

}

else
{
var textNode = document.createTextNode("No records matched.");

}
}
}

//-->

</script>
<script>
alert("Testing")
</script>

</head>

<body onload="initPage()">

<div id="output"></div>

</body>

</html>
mikefmikef
M.

I would suggest you start coding in the product version of the AJAX api, the beta version will always be around but the new version will be supported in the future.
    To do this there is a how to in the help doc here.

Now I don't know what kind of stuff you want to do with the other web site.
Do you want to just login and go to the UI?
Or do you want to push SFDC solution data to another web service?

If you just want the next screen to be the new web site, then you can popup a simple html page asking for their username and password, please use the input type password, and then pass the username and password to the new web site using https. Redirect your scontrol to the new site.

If you want to pass data to the new web site, then you have to make sure they have an Ajax API and create XMLHttpRequest to their web service, passing the login info. You can get more info on doing this at http://developer.mozilla.org/en/docs/AJAX:Getting_Started.
webdevwebdev
Hi,

were you able to accomplish it? if yes, can you please give me some sample code?

Thanks,
mikefmikef
A sample login request is in the AJAX docs.

As for the XmlHTTPRequest you have to make sure the web site you want to pass data to allows we connections.

Not sure what you are asking for.