• mrochcmu
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I'm trying to develop in Flex Builder 3, but I doesn't seems to be able to Log In.

 

Here is what I'm trying to do:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:airforce="http://www.salesforce.com/air"
applicationComplete="initApp()" horizontalScrollPolicy="off" status="{airConnection.connected ? 'Online' : 'Offline'}" xmlns:salesforce="http://www.salesforce.com/">

<mx:Script>
<![CDATA[
import mx.controls.Alert;
import com.salesforce.objects.SObject;
import com.salesforce.results.QueryResult;
import com.salesforce.AsyncResponder;
import com.salesforce.objects.LoginRequest;

private function initApp():void
{
var lr:LoginRequest = new LoginRequest({
server_url: this.parameters.server_url,
session_id: this.parameters.session_id,
username: "UsernameONLY",
password: "PasswordONLY",
callback: new AsyncResponder(function (result:Object):void { getContacts(); })
});
airConnection.login(lr);
}

private function getContacts(o:Object=null):void
{
Alert.show(airConnection.connected.toString());
if (airConnection.connected) {

Alert.show(airConnection.IsLoggedIn.toString());

airConnection.query("Select Id, FirstName, LastName From Contact LIMIT 10", new AsyncResponder(
function (qr:QueryResult):void {
dg.dataProvider = qr.records;
},handleFault)
);
}
}

private function handleFault(fault:Object):void
{
Alert.show('ERROR : ' + fault.toString());
}


]]>
</mx:Script>

<!-- <airforce:AIRConnection id="airConnection"/> -->
<salesforce:AIRConnection id="airConnection"/>

<mx:DataGrid id="dg" width="100%" height="100%"/>

<mx:HBox>
<mx:Button label="Get Contacts" click="getContacts()"/>
<mx:Button label="Create New Contact">
<mx:click>
var acc:SObject = new SObject('Contact');
acc.FirstName = 'Test';
acc.LastName = 'Contact ' + (new Date()).time;

airConnection.create([acc], new AsyncResponder(
function (result:Object):void
{
getContacts();
})
);
</mx:click>
</mx:Button>
<mx:Button label="Force Offline" click="airConnection.forceNetworkStatusChange(false)" enabled="{airConnection.connected}"/>
<mx:Button label="Force Online" click="airConnection.forceNetworkStatusChange(true)" enabled="{!airConnection.connected}"/>
</mx:HBox>

</mx:WindowedApplication>

 

 In this code, the BLUE colored Alert Line displayed "true" (i.e. Connection is Connected). The RED colored Alert Line displays "False" (i.e. User is Not Logged In, DESPITE providing the correct Username and Password to my Developer Org).

Also, I tried calling the Fault Handle function to Query function, but it also doesn't seems to be working, this Error is thrown on clicking the "Get Contacts" button:

 

query - offline
SQLError: 'Error #3115: SQL Error.', details:'no such table: 'Contact'', operation:'execute', detailID:'2013'
Select Id, FirstName, LastName FROM `Contact` LIMIT 10;
SQLError: 'Error #3115: SQL Error.', details:'no such table: 'Contact'', operation:'execute', detailID:'2013'
Select Id, FirstName, LastName FROM `Contact` LIMIT 10;

 

Can anybody help me. I was looking to get started with FLEX development but doesn't seems to get things right :(.

 

 

ALSO please note that I have to disable <airforce:AIRConnection> this Line of code from the actual tutorial. Do this seems to be an issue because using this was cauing this exception:

 

"Could not resolve <airforce:AIRConnection> to a component implementation"

 

Message Edited by vchaddha on 05-28-2009 11:55 PM