You need to sign in to do that
Don't have an account?
Vintara
Flex applications and force.com authentication.
I have an existing application developed with Adobe Flex and the Salesforce Flex/Flash object library. My understanding is that the current implementation requires a browser authenticated session for the Flex application to inherit in order to connect to the Salesforce data objects. However, there is no such authentication occurring if I try to host my app in a force.com site.
Any thoughts as to how to resolve this issue? Perhaps user authentication through force.com? However that option seems to be disabled in the developer preview.
Any thoughts as to how to resolve this issue? Perhaps user authentication through force.com? However that option seems to be disabled in the developer preview.
I finally solved this problem but it wasn't easy to figure out. In order to get this working I had to create an SControl for my Flex component. When you call the SControl versions of $API.Session_ID, it gives you the proper id to interact with the Web Services API. Obviously, this is only important if you need to do a query from your Flex. In the SControl component I put all the code from the "main.html" which is generated when you build your Flex component with the Flex Builder. I think by default it goes into the "bin-debug" directory of your Flex project. I also loaded up the AC_OETags.js file into Salesforce. I loaded all my components as Documents -- the Javascript and the Flash file -- rather than Static Resources. The AC_OETags.js creates the Object and Embed tags on the fly and tries to attach .swf to the end your url. I don't believe you can load up a document with a file extension as a static resource.
There is also an undocumented issue with Salesforce connection object. You need to declare a connection object in your code and point the connection to specific server to resolve a connection error. I believe this has to do with some security enhancements which Adobe made to the flash plugin recently.
Are you saying I should put a javascript login system to ensure that the API.Session_ID is set?
I didn't find that worked for me, but I'm not sure our situations are exactly the same. When I just laid the HTML as you have in an SControl the $API.Session_ID worked fine. I could login to Salesforce but I couldn't get the record id of my custom object to populate dynamically to the Flashvars. The result was a poorly formed query with an error. It looks like to me though that the last parameter of your flashvar param string is static:
Message Edited by Wardster on 12-17-2008 01:28 PM
Message Edited by Wardster on 12-17-2008 02:04 PM
Here is a revised code sample of the complete component.
I'm having a similar problem and wonder if there is an easy answer here. I can get data just fine, hooking into prod, hardcoding my connection information. When I try to monkey with parameterizing this so that the page (visualforce, not sControl) passes in flashvars
, I can't do that with a page that has a standard controller so I removed all the other code on the page including the standardController tag for the page and just made the page the embedded flex object. The query appears to be 'spinning' - the bottom of the page shows 'Transferring data from cross-domain.xml but nothing comes back. any ideas on how to debug this?private function login(event:Event):void {
var lr:LoginRequest = new LoginRequest();
lr.server_url = parameters.server_url;
lr.session_id = parameters.session_id;
lr.callback = new AsyncResponder(getCandidateSOs);
connection.login(lr);
}
private function getCandidateSOs(o:Object=null):void
{
connection.query("Select Id, Name, Product__c, Account__c from Service_Order__c where Order_Stage__c = 'Customer Signature'"
, new AsyncResponder(
function (qr:QueryResult):void {
candidateSOs.dataProvider = qr.records;
}));
}
The $ in front of the Visualforce global variables are missing, which would explain why no data was being passed (don't know if this was a requirement back in Feb-09.)
I'm trying to parameterize as well (swf in test org gets test org data, swf in prod gets prod data operating as the logged in user) as well by using the session_id passed via flashvars. I'm getting the session ID, but no query results. Any assistance would be greatly appreciated!
Here's the approach as of this posting:
--Edit--
The toolkit doesn't seem to support the Enterprise endpoint; replacing that with the $API.Partner_Server_URL_190 made this function.
--end edit--