You need to sign in to do that
Don't have an account?

sforceClient.Login within an sControl
Is it possible to use sforceClient.Login within an sControl rather than sforce.init? I would like to allow my sControl to login as an adminstrative user as a security work-around, but I keep getting errors when calling the Login method.
Thanks.
You must call init though. Try this:
Code:
Here is the code for the full control if that helps:
<html>
<head>
<title>Delete Sample Item</title>
<script src="https://www.sforce.com/ajax/beta1/sforceclient.js" type="text/javascript"></script>
<script language="javascript">
<!--
function initPage()
{
sforceClient.useCookies = true;
sforceClient.registerInitCallback(setup);
sforceClient.init(null, null, false);
window.setTimeout(";", 1000);
var Sample = "{!Sample_ID}";
processRun(Sample);
}
function setup() {
alert(sforceClient.login("admin@mydomain.com", "mypassword"));
}
function processRun(Sample) {
sforceClient.Delete("{!Sample_Item_ID}");
redirect(Sample);
}
function redirect(SampleId) {
parent.frames.location.replace("/" + SampleId)
}
//-->
</script>
</head>
<body onload="initPage();" style='background-color:#ffffff;color:#000000;'>
<div id="divMain">
</div>
</body>
</html>
https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js
I have updated to 3.3, but now I get an "Unknown name" error on the login call. I am using my own username and password to test so I'm sure they are correct. any more thoughts?
Thank you!
Code:
Hmm... what browser and os?
Can you get a simple scontrol that only logs in to work in IE from the file system?
Would I be correct in saying, that using this method, anyone could click on View|Source and looking at the code could then get the username and password?
Is there anyway to do this but also hide/encrypt the username and password?
Nothing leaps to mind except obfuscation. (Like building the username and password byte by byte in hex, backwards, or other laughable approaches. At the end of the day though, the enterprising thief can work around it and get it.)
Seems like a bad idea.
It looks like the original goal was to delete some records. Perhaps instead, the record ID's to be deleted could be stored in a custom object of "Things to be Deleted". And then once in awhile a "real" admin will come around and execute an s-control which will take the id stored in every record of that table and delete it. Sure, it's housekeeping, but if you don't want to just grant the users the needed permissions... :-)
Steve Bower.
DevAngel,
I am getting this error on some of the machines here as well. Works perfectly on my machine OS=Win2003 Standard, Browser=IE6 but on on OS=WinXP, Browser=IE6. The line that fails is
Code:
Which like Jesip stated, errors on line 904 - Unknown Name. Thoughts?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<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("myLogin", "myPassword")
alert(loginResult);
</script>
</BODY>
</HTML>