0 Replies Latest reply on Sep 24, 2010 11:16 AM by Ashu***

    New Bie Question: Doing Flex Salesforce integration for the first time

    Ashu***

      Dear Friends,

       

      I want to connect to Salesforce using Flex API and I have tried two-three approaches but all in vain.

      It give me an error 'INVALID_LOGIN: Invalid username, password, security token; or user locked out.'

       

      PLEASE HELP ME TO FIX THIS .

       

      Also, I would like the highlight the fact that my username and password work only for 'test.salesforce.com' and not for ' login.salesforce.com'. Could it be reason for login failure. I have used the token as suggested.

      I have also tried setting different serverURL like ''serverUrl=https://test.salesforce.com/services/Soap/u/9.0 and https://login.salesforce.com/services/Soap/u/9.0 .

       

      Below are two of the techniques I have used.

       

      '

       

      (1) Using AIR API.

      For this I have done as mentioned in 'http://wiki.developerforce.com/index.php/Force.com_Flex_Quick_Start_Tutorial'.

       

      (2) Trying to tun the below code, that I found in one of the quick start tutorial.

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:WindowedApplication

       

       

      xmlns:fx="http://ns.adobe.com/mxml/2009"

      xmlns:s="

      library://ns.adobe.com/flex/spark"

      xmlns:mx="

      library://ns.adobe.com/flex/mx" xmlns:salesforce="http://www.salesforce.com/">

       

       

       

      <fx:Declarations>

       

       

      <salesforce:AIRConnection id="force"/>

       

       

      <!-- Place non-visual elements (e.g., services, value objects) here -->

       

       

      </fx:Declarations>

       

       

      <mx:DataGrid id="dgSolutions" right="10" top="10" left="10" bottom="10" />

       

       

       

      <fx:Script>

      <![CDATA[

       

       

      import com.salesforce.AsyncResponder;

       

      import com.salesforce.objects.LoginRequest;

       

      import com.salesforce.results.LoginResult;

       

      import com.salesforce.results.QueryResult;

       

       

      import mx.collections.ArrayCollection;

       

      import mx.controls.Alert;

       

      import mx.rpc.AsyncRequest;

       

       

      private function init():void {

       

      var lr:LoginRequest = new LoginRequest();

      lr.username =

      'myusername'; // I have given my username here

      lr.password =

      'mypassword'; // I have given my password here

      lr.callback =

      new AsyncResponder(loadGrid);

      force.login(lr);

      }

       

       

      private function loadGrid(lr:LoginResult):void {

      Alert.show(

      'Hi');

      force.query(

      "Select Id, FirstName, LastName From Contact",

       

      new AsyncResponder( function (qr:QueryResult):void {

      dgSolutions.dataProvider = qr.records;

      })

      );

      }

       

      ]]>

       

      </fx:Script>

       

      </s:WindowedApplication>

       

       

      ANYHELP IN THIS REGARD WOULD BE REALLY APPRECIATED.

      THANKS IN ADVANCE.