• fdask
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hey everyone.  Just let me preface by saying what a great resource I've found these boards to be.  When I'm absolutely stuck I can usually turn here and find a response.  Thanks everyone for pitching in.

Now for my question.

I'm using Flex, and trying to populate a DataGrid with ActivityHistory results for an Account.   My simple code is below

Code:
<—xml version="1.0" encoding="utf-8"–>
<mx:Application creationComplete="login(event)" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:salesforce="http://www.salesforce.com/">
 <salesforce:Connection id="apex" serverUrl="https://www.salesforce.com/services/Soap/u/9.0" />
 
 <mx:Script>
  <![CDATA[
   import mx.collections.ArrayCollection;
   import com.salesforce.results.QueryResult;
   import mx.utils.ObjectUtil;
   import mx.controls.Alert;
   import com.salesforce.AsyncResponder;
   import com.salesforce.objects.LoginRequest;
   
   private function login(event:Event):void {
    var lr:LoginRequest = new LoginRequest();
    lr.username = "my username";
    lr.password = "my password";
    lr.callback = new AsyncResponder(loadData, handleFault);
    apex.loginWithCredentials(lr.username, lr.password, lr.callback);
   }

   [Bindable]
   private var tmp:ArrayCollection = new ArrayCollection();
   private var activityHistory:ArrayCollection = new ArrayCollection();
   
   private function handleFault(fault:Object):void {
    Alert.show(ObjectUtil.toString(fault));
   }
   
   private function loadData(lr:Object):void {
    apex.query("SELECT (SELECT ActivityHistory.WhoId, ActivityHistory.Subject, ActivityHistory.ActivityDate FROM Account.ActivityHistories LIMIT 20) FROM Account WHERE Account.Id='REAL ACCOUNT ID HERE'", new AsyncResponder(
     function(qr:QueryResult):void {
      if (qr.size > 0) {
       tmp = qr.records;
       activityHistory = tmp.getItemAt(0).ActivityHistories.records;
      }
     }, 
     handleFault)
    );
   }
  ]]>
 </mx:Script> 
 
 <mx:DataGrid dataProvider="{activityHistory}" width="587" x="10" height="386" y="10">
  <mx:columns>
   <mx:DataGridColumn dataField="WhoId"/>
   <mx:DataGridColumn dataField="Subject"/>
   <mx:DataGridColumn dataField="ActivityDate"/>   
  </mx:columns>
 </mx:DataGrid>
</mx:Application>
When I compile the app, I get a warning stating 'Data binding will not be able to detect assignments to activityHistory'.

The app loads, but the data grid never gets populated.

At first the result was pulling over 1000 activity history entries, so I thought that might be the issue, so I added the limit.  That's working, but still the data grid remains emtpy.

If I alert individual values from the activityHistory ArrayCollection, I see the data.  Running in debug mode, I see activityHistory gets the data in to it.

What am I doing wrong?   I'm sure it's something simple, but I'm pulling out my hair here trying to figure it out.

Finally, I'm not even sure I'm using the right approach to getting the data from the subquery out... couldn't find a good example for that either.

Any help would be most appreciated!

Thank you kindly.
 

  • July 05, 2007
  • Like
  • 0
Hey everyone.  Just let me preface by saying what a great resource I've found these boards to be.  When I'm absolutely stuck I can usually turn here and find a response.  Thanks everyone for pitching in.

Now for my question.

I'm using Flex, and trying to populate a DataGrid with ActivityHistory results for an Account.   My simple code is below

Code:
<—xml version="1.0" encoding="utf-8"–>
<mx:Application creationComplete="login(event)" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:salesforce="http://www.salesforce.com/">
 <salesforce:Connection id="apex" serverUrl="https://www.salesforce.com/services/Soap/u/9.0" />
 
 <mx:Script>
  <![CDATA[
   import mx.collections.ArrayCollection;
   import com.salesforce.results.QueryResult;
   import mx.utils.ObjectUtil;
   import mx.controls.Alert;
   import com.salesforce.AsyncResponder;
   import com.salesforce.objects.LoginRequest;
   
   private function login(event:Event):void {
    var lr:LoginRequest = new LoginRequest();
    lr.username = "my username";
    lr.password = "my password";
    lr.callback = new AsyncResponder(loadData, handleFault);
    apex.loginWithCredentials(lr.username, lr.password, lr.callback);
   }

   [Bindable]
   private var tmp:ArrayCollection = new ArrayCollection();
   private var activityHistory:ArrayCollection = new ArrayCollection();
   
   private function handleFault(fault:Object):void {
    Alert.show(ObjectUtil.toString(fault));
   }
   
   private function loadData(lr:Object):void {
    apex.query("SELECT (SELECT ActivityHistory.WhoId, ActivityHistory.Subject, ActivityHistory.ActivityDate FROM Account.ActivityHistories LIMIT 20) FROM Account WHERE Account.Id='REAL ACCOUNT ID HERE'", new AsyncResponder(
     function(qr:QueryResult):void {
      if (qr.size > 0) {
       tmp = qr.records;
       activityHistory = tmp.getItemAt(0).ActivityHistories.records;
      }
     }, 
     handleFault)
    );
   }
  ]]>
 </mx:Script> 
 
 <mx:DataGrid dataProvider="{activityHistory}" width="587" x="10" height="386" y="10">
  <mx:columns>
   <mx:DataGridColumn dataField="WhoId"/>
   <mx:DataGridColumn dataField="Subject"/>
   <mx:DataGridColumn dataField="ActivityDate"/>   
  </mx:columns>
 </mx:DataGrid>
</mx:Application>
When I compile the app, I get a warning stating 'Data binding will not be able to detect assignments to activityHistory'.

The app loads, but the data grid never gets populated.

At first the result was pulling over 1000 activity history entries, so I thought that might be the issue, so I added the limit.  That's working, but still the data grid remains emtpy.

If I alert individual values from the activityHistory ArrayCollection, I see the data.  Running in debug mode, I see activityHistory gets the data in to it.

What am I doing wrong?   I'm sure it's something simple, but I'm pulling out my hair here trying to figure it out.

Finally, I'm not even sure I'm using the right approach to getting the data from the subquery out... couldn't find a good example for that either.

Any help would be most appreciated!

Thank you kindly.
 

  • July 05, 2007
  • Like
  • 0