Executing multiple queryTasks with a relationshipTask in the middle

619
2
Jump to solution
11-28-2012 09:43 AM
AndrewBrown1
Occasional Contributor II
I'm trying to execute multiple query tasks, where the second queryTask depends on a relationshipTask result from a featureLayer after the first queryTask. It'll look something like this


queryTask1()
     relationshipTask(necessary input from queryTask1 result)
queryTask2(necessary input from relationshipTask within queryTask1)

I tried using the ESRI example, "Multiple query results with deferred list", but I cannot figure out how to do it the way that works for me.

I'm querying a view within the first queryTask to retrieve objectids and an integer, then I'm using a relationshipQuery with the objectids to retrieve a list of strings. I'm using the list of strings to query a 3rd view within the second queryTask to display the results in a dojo table.

Is using a deferredList the way to go? If so, could somebody please provide an example of how to do this?

Thanks,
Andrew
0 Kudos
1 Solution

Accepted Solutions
JanJeske
New Contributor III
I hobe i understand it right you want to do a query. With the Results of the query you want to call a second and with the second a third?

function callquery1(params) {     queryTask = new esri.tasks.QueryTask(queryurl);     query = new esri.tasks.Query();     query.returnGeometry = true;     query.outFields = ["*"];      query.where = "id = '" + params+ "'";     //either     queryTask.execute(query,function(results){   here create your second query      });     //or     queryTask.execute(query,callquery2); } function callquery2(results) {     //with the results you bild you second params     console.log(results); //write the results to the console check firebug or dom inspektor     queryTask = new esri.tasks.QueryTask(queryurl);     query = new esri.tasks.Query();     query.returnGeometry = true;     query.outFields = ["*"];      query.where = "id = '" + params+ "'";     //either     queryTask.execute(query,function(results){   here create your thirdquery      });     //or     queryTask.execute(query,callquery3); } 


Hope it helps 🙂 and i hope i understand waht you want to do 😉

View solution in original post

0 Kudos
2 Replies
JanJeske
New Contributor III
I hobe i understand it right you want to do a query. With the Results of the query you want to call a second and with the second a third?

function callquery1(params) {     queryTask = new esri.tasks.QueryTask(queryurl);     query = new esri.tasks.Query();     query.returnGeometry = true;     query.outFields = ["*"];      query.where = "id = '" + params+ "'";     //either     queryTask.execute(query,function(results){   here create your second query      });     //or     queryTask.execute(query,callquery2); } function callquery2(results) {     //with the results you bild you second params     console.log(results); //write the results to the console check firebug or dom inspektor     queryTask = new esri.tasks.QueryTask(queryurl);     query = new esri.tasks.Query();     query.returnGeometry = true;     query.outFields = ["*"];      query.where = "id = '" + params+ "'";     //either     queryTask.execute(query,function(results){   here create your thirdquery      });     //or     queryTask.execute(query,callquery3); } 


Hope it helps 🙂 and i hope i understand waht you want to do 😉
0 Kudos
AndrewBrown1
Occasional Contributor II
I was able to solve my issue. I removed the relationshipQuery and nested the queryTasks so they'll fire in the correct order, which worked perfectly.

Thanks anyhow!
0 Kudos