javascriptdojoarcgisarcgis-js-api

Multiple query using QueryTask ArcgGIS JS Api 3


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


Solution

  • 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