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

Automatic login via a custom button to another Web
I need a custom button in Salesforce that It redirect in other web
I need a custom button that redirects to another web and will automatically log. The external web only reveives by POST.
*** I'm trying to do the following. This returns the HTML of the web. But do not know how to paint.
public pagereference contactSend2() {
HttpRequest req= new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://extranet.groupalia.com/user/login');
req.setMethod('POST');
req.setBody('username=***&password=***');
res = http.send(req);
return null;
}
*** Also I'm trying this:
public static HTTPResponse contactSend() {
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('http://extranet.groupalia.com/user/login');
req.setBody('username=***&password=***');
req.setTimeout(60000);
Http http = new Http();
HTTPResponse res = http.send(req);
return res;
}
Please anyone have any idea? I'm going crazy.
Sergio.
You can try something following from JavaScript:
Another reference: http://en.allexperts.com/q/Javascript-1520/create-form-submit-fly.htm
All Answers
one option can be creating the html form in the JavaScript and setting its method as Post, action URL as your endpoint.
Thanks Prasanna.
So I understand that the code is incorrect to use what I try to do. What do I need to use methods to redirect to an external website, and to authenticate? Is that possible?
Sergio.
You can try something following from JavaScript:
Another reference: http://en.allexperts.com/q/Javascript-1520/create-form-submit-fly.htm
I love you, Prasana! Thanks a lot!
IN JavaScript Button;
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var submitForm = document.createElement("FORM");
document.body.appendChild(submitForm);
submitForm.method = "POST";
var newElement = document.createElement("input");
newElement.setAttribute('type',"text");
newElement.setAttribute('name','username');
submitForm.appendChild(newElement);
newElement.value = '{!Co.email}';
var newElement = document.createElement("input");
newElement.setAttribute('type',"text");
newElement.setAttribute('name',password);
submitForm.appendChild(newElement);
newElement.value = '{!Co.Password__c}';
submitForm.action= "http://extranet.tictac.com/user/login";
submitForm.submit();