Select to view content in your preferred language

QueryTask executeRelationshipQuery Issue

1350
4
05-25-2010 07:07 AM
JoseSousa
Esri Contributor
Dear ArcGIS API Flex Team,

I have a weird bug.

I have two widgets:

1 - Selection Widget - In Declaration tag defines a QueryTask like: <esri:QueryTask id="queryTask" showBusyCursor="true" useAMF="true" />; This will be used for a simple query.
2 - Identify Widget - In Declaration tag defines a QueryTask like: <esri:QueryTask id="queryTask" showBusyCursor="true" useAMF="true" />; This will be used for a relationship query.

Issues:
EVERYTIME I open first the selection widget and then the identify widget and try to execute the code behind {1} I get an error {2}. I do not use anything of the selection widget. I just open the widget to initialize the QueryTask.

{1} Code:

      var query:RelationshipQuery = new RelationshipQuery();
      query.objectIds = [featureId];                   
      query.relationshipId = relationshipId;                   
      query.outFields = ["*"];
      query.returnGeometry = true; //Para permitir que possa fazer zoom à feature
      query.outSpatialReference = map.spatialReference;
      queryTask.url = layerUrl;
      queryTask.executeRelationshipQuery(query, new AsyncResponder(onRelationshipQueryResult, onRelationshiptQueryFault, node));
           
      function onRelationshipQueryResult(result:Object, token:Object = null):void                   
      {   
                                                                                                }

{2} Error:

ReferenceError: Error #1056: Cannot create property spatialReference on com.esri.ags.tasks.supportClasses.RelatedRecordGroup.
at com.esri.ags.tasks::QueryTask/handleRelationshipQuery()
at Function/http://adobe.com/AS3/2006/builtin::call()
at com.esri.ags.tasks::BaseTask/loaderCompleteHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

If I open first the identify widget and then the selection widget it works just fine ...

Can Flex Team check if this is a bug?

Thanks a lot,

José Sousa
ESRI Portugal
Tags (2)
0 Kudos
4 Replies
DasaPaddock
Esri Regular Contributor
Here's a couple of changes you can try.

1. Create an instance of QueryTask in index.mxml. This is just so that QueryTask will be in the app's ApplicationDomain, instead of being loaded by each module.

2. Set useAMF to false.

Can you let us know if either of these changes fixes this problem?
0 Kudos
JoseSousa
Esri Contributor
Dear Dasa,

I don't want to share a single instance of QueryTask to all application. Sometimes I initialize this instance in each widget using Actionscript. I know the advantages of having a single instance shared by all applications, but in my case I want to allow that everyone can upload widgets to my application without knowing my classes.

But I have tried setting the useAMF to false and it worked. Unfortunetely this tells me that there is an issue with this QueryTask Class when executing the method executeRelationshipQuery. Using AMF is a major add in in every query so I hope you can figure it out what is happening.

Thanks a lot,

José Sousa
ESRI Portugal
0 Kudos
DasaPaddock
Esri Regular Contributor
You don't need to use the instance you create in the main app. If you create it there, the class definition won't be loaded by each module. It's similar to class loader issues in Java if you're familiar with that.

Here's a good reference:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-799a.html#WS2db454920e96...
0 Kudos
JoseSousa
Esri Contributor
Hello Dasa,

Your suggestion worked. Thanks for your precious help and your link explaining the concept very well.

Thanks a lot,

José Sousa
ESRI Portugal
0 Kudos