+ Start a Discussion
MattLMattL 

Timeout on Query in Adobe Flex

What, generally speaking, is the problem when you have a Flex graph that loads, but times out (Firefox sits there on "Transfering data from na1.salesforce.com" forever)?

Here's my code.

Code:
apex.query("Select Id from SFDC_Resource__c",
     new AsyncResponder(
     function (qr:QueryResult):void
     {
       for(var x:int=0;x<qr.records.length;x++)
       {
        apex.query("Select Hours, Resource__c, Resource__r.Id, Projects__c, Projects__r.Id from SFDC_Assignment__c Where Resource__c='"+qr.records[x].Id+"' and Projects__c='"+currId+"'",
        new AsyncResponder(
       function (qr2:QueryResult):void
        {
         var tempHours:int=qr2.records[0].Hours;
         for(var y:int=1;y<qr2.records.length;y++)
         {
       tempHours+=qr2.records[y].Hours;
         }
         resHours.addItem({Hours:tempHours, Resource:qr.records[y].Id});
        },
        function (fault:Object):void {}
       ));
       }
     },
     function (fault:Object):void {}
        ));

 

SuperfellSuperfell
Only marginly related, but this query

 Select Hours, Resource__c, Resource__r.Id, Projects__c, Projects__r.Id from SFDC_Assignment__c Where Resource__c='"+qr.records[x].Id+"' and Projects__c='"+currId+"'",

selects both resource__c and resource__r.id (and the same for projects c/r) these two fiels will hold exactly the same value as resource__c is the FK field on the base row, and resource__r.Id is the id of the row that the FK points to, this by definition is the same value. you should just select the __c versions, which should execute quicker because then we can skip the extra joins.
MattLMattL
Thanks for the tip. So I can just omit the __r entirely? And just reference it as Resource__c.Id? The reason my query was formed like that was because that was how the Apex Xplorer formatted it, so I thought it was required when doing referenced queries.

As for my original problem, I solved it after someone recommended ServiceCapture. A lot easier than just guess-and-checking. Turns out, Hours should be Hours__c, as Assignment is a custom object.