+ Start a Discussion
anup ramanup ram 

Salesforce sites with Flex error

I have a simple logic on flex to login to salesforce and create a record. The flex swf when embedded on VF page works fine internal to salesforce. But my requirement is to display the flex on site page to create record. The login fails on the same page when accessed through public sites. Any help is very appreciated.

Error is security error accessing url and also destination: default http

I am not sure how to use flex on salesforce sites to create record in salesforce.

    import com.salesforce.*;
    import com.salesforce.objects.*;
    import com.salesforce.results.*;
    import mx.controls.Alert;
        import com.salesforce.AsyncResponder;
        import com.salesforce.events.ApexFaultEvent;
        import com.salesforce.objects.LoginRequest;
        import com.salesforce.objects.SObject;
        import com.salesforce.results.Fault;
        import com.salesforce.results.LoginResult;
        import com.salesforce.results.QueryResult;
        import com.salesforce.results.UpsertResult;

    [Bindable] public var sfdc:Connection = new Connection();

    private function login():void {

        var lr:LoginRequest = new LoginRequest();
        sfdc.protocol = "https";
        sfdc.serverUrl = "https://login.salesforce.com/services/Soap/u/14.0";
    lr.username = "uname.com";
                           lr.password = "pwdsectoken";

        lr.callback = new AsyncResponder(loginSuccess, loginFault);



    private function submitForm():void {

        var aSo:Array = new Array();
        var so:SObject = new SObject("Contact");
        so.FirstName = firstName.text;
        so.LastName = lastName.text;
        so.Email = email.text;


            new AsyncResponder(
                function (obj:Object):void {
                    if (obj[0].success == true) {
                        Alert.show("Created record: "+obj[0].id);
                    } else {
                }, sfdcFailure


    private function loginSuccess(result:Object):void {
        contactForm.enabled = true;

    private function sfdcFailure(fault:Object):void {

    private function loginFault(fault:Object):void
        Alert.show("Could not log into SFDC: "+fault.fault.faultString,"Login Error");
        Alert.show("error " + fault.fault.faultDetail);

<mx:Text text="To create a new Contact, Last Name is required by Salesforce.com while Email is required via a custom validation rule. &#xd;&#xd;Submit the form with different combinations to view the resulting messages returned from Salesforce.com.&#xd;" width="449"/>
<mx:Form id="contactForm" width="100%" height="100%" enabled="false">
    <mx:FormItem label="First Name">
        <mx:TextInput id="firstName"/>
    <mx:FormItem label="Last Name">
        <mx:TextInput id="lastName"/>
    <mx:FormItem label="Email">
        <mx:TextInput id="email"/>
        <mx:Button label="Submit" click="submitForm()"/>