0

I am using QueryTask in ArcgGIS JS Api 3 and I want to execute multiple query in one call, I took a look at the documentation and I didn't find the possibility to do it

this is what I am using


arraygraphic.map(async (e)=>{
        let query = new esri.tasks.Query();
        query.where = "id = '"+id+"'";
        query.outFields = ["*"];
        let response = await queryTask.execute(query)
      })

and this is what I want to do


let queryList=[];
arraygraphic.map(async (e)=>{
        let query = new esri.tasks.Query();
        query.where = "id = '"+id+"'";
        query.outFields = ["*"];
        queryList.push(query)
      })
let response = await queryTask.execute(queryList)

any suggestion or help ? thank you in advance

2 Answers 2

1

You can only have one "Query", but you can create a better where statement that searches for all the "id" in a single where statement.

Your where statement would end up looking something like: id in (1,2,3,4).

You can find more details about the supported SQL under "Request parameters" at https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm#GUID-62EE7495-8688-4BD0-B433-89F7E4476673

1

If you're not able to put all the queries in one SQL statement as Bjorn suggested (e.g. queries to multiple layers), then you can add the requests to an array and use promise.all to send all the requests https://developers.arcgis.com/javascript/3/jssamples/query_deferred_list.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.