You need to sign in to do that
Don't have an account?
as3Salesforce.swc - Flex Toolkit no longer working?
I'm befuddled and puzzled. I just got the Google Maps API for Flex to embed properly in SF and now I am trying to get a data grid to fill with SF data in the same SWF. I've gotten data out of Salesforce in the past using the as3salesforce.swc library but it doesn't seem to work anymore. I've been following threads about the appropriate server_url (which I've now replaced with v15 to no avail). Anybody else noticing problems with the toolkit?
<apex:page standardController="Location__c">
<apex:form >
<apex:pageBlock title="Flex implementation">
<apex:flash id="flexSOs" src="{!$Resource.SFFlex}" height="100%" width="100%"
flashvars="session_id={!$Api.Session_ID}&server_url={!$Api.Partner_Server_URL_150}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
Here's the mxml code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:salesforce="http://www.salesforce.com/"
creationComplete="login(event)"
viewSourceURL="srcview/index.html">
<salesforce:Connection id="connection"/>
<mx:Script>
<![CDATA[
import com.salesforce.objects.SObject;
import com.salesforce.results.QueryResult;
import com.salesforce.AsyncResponder;
import com.salesforce.objects.LoginRequest;
import mx.core.IUIComponent;
import mx.managers.DragManager;
import mx.events.DragEvent;
import mx.collections.ArrayCollection;
import flash.external.ExternalInterface;
[Bindable]
public var selectedItem:Object;
[Bindable]
public var selectedSOs:ArrayCollection = new ArrayCollection();;
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, A_Loc__c from Service_Order__c"
, new AsyncResponder(
function (qr:QueryResult):void {
candidateSOs.dataProvider = qr.records;
}));
}
]]>
</mx:Script>
<mx:Form id="frmPrintSO"
width="100%" height="75%"
borderStyle="solid" borderColor="#D4D4D4"
dropShadowEnabled="true" dropShadowColor="#B3B3B3"
shadowDirection="right" shadowDistance="10">
<mx:FormHeading label="Signature SOs" />
<mx:HBox>
<mx:VBox>
<mx:Label text="Candidate SOs"/>
<mx:DataGrid id="candidateSOs"
allowMultipleSelection="true"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true">
<mx:columns>
<mx:DataGridColumn dataField="Name"/>
<mx:DataGridColumn dataField="A_Loc__c"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:HBox>
</mx:Form>
</mx:Application>
If you get errors about invalid sessions, I noticed that the {!$Api.Session_ID} approach isn't always working. Why, I have no idea, but I got it working by using a Controllerextension which uses Apex to get the current session ID instead.
public class GetSessionControllerExtension {
public GetSessionControllerExtension(ApexPages.StandardController stdController) {
}
public String GetMySessionId() {
return UserInfo.getSessionId();
}
}
All Answers
If you get errors about invalid sessions, I noticed that the {!$Api.Session_ID} approach isn't always working. Why, I have no idea, but I got it working by using a Controllerextension which uses Apex to get the current session ID instead.
public class GetSessionControllerExtension {
public GetSessionControllerExtension(ApexPages.StandardController stdController) {
}
public String GetMySessionId() {
return UserInfo.getSessionId();
}
}
That is very strange, i'm glad you got it working.
Those session ID's should be the same, unless i'm missunderstanding something.
Yes, that was my understanding also. And interestingly enough, sometimes it works. Sometimes it doesn't. I tried it with several different Orgs, Enterprise and Developer, with namespaces and without and couldn't find a pattern to track it down reliably.
It might depend on the cluster the org is residing on, but that's just a guess.
Maybe someone from the SFDC Dev team can look into it?