AnsweredAssumed Answered

javascript api 3.11 query task error " undefined is not a function"

Question asked by rupali00 on Jan 14, 2015
Latest reply on Jan 14, 2015 by rupali00

Can someone please help me with the code below.

I have been struggling to find why I am getting "Uncaught TypeError: undefined is not a function" error

at   QueryTask.execute(Qry,showResults);






























  "esri/tasks/query", "esri/tasks/QueryTask"

   ], function(

  Map, ArcGISDynamicMapServiceLayer, BasemapToggle, FindTask, FindParameters, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol,

  Color, on, dom, registry, arrayUtils, connect, DataGrid, ItemFileReadStore, Button, parser, Memory, FilteringSelect, ComboBox, Query, QueryTask


) {

  var findTask, findParams;

  var Query, QueryTask;

  var map, center, zoom;

  var infoTemplate;

  var grid, store;


  = "";

  infoTemplate = new esri.InfoTemplate(


  "Available Acres: ${MKTG_AVL_A}<br />Zone: ${ZO_ZONE}<br />Company: ${MKTG_Contact}<br />Contact: ${MKTG_CON_FN} ${MKTG_CON_LN} <br />   ${MKTG_CON_St}    ${MKTG_CON_city} ${MKTG_CON_State} ${MKTG_CON_zip}<br />   ${MKTG_CON_ph}<br />   ${MKTG_CON_email}");


  registry.byId("search").on("click", doFind);

  registry.byId("search1").on("click", doFind1);

  registry.byId("searchQry").on("click", QryExe);


  center = [-77.4875, 39.0436];

  zoom = 11;

  map = new esri.Map("map", {

        basemap: "topo",

        center: center,

        zoom: zoom

   //infoWindow: infoWindow




  var toggle = new BasemapToggle({map: map,

        basemap: "satellite"}, "BasemapToggle");



  QueryTask = new QueryTask("http://agstest................................./MapServer/0");


        //Create Find Task using the URL of the map service to search

  findTask = new FindTask("http://agstest........................./MapServer");



  // add dynamic map service layer

        var urlDyn = "http://agste................................./MapServer";

        var usaLayer = new ArcGISDynamicMapServiceLayer(urlDyn, {

          id: "acres",

          opacity: 0.45,

          visible: true





        map.on("load", function () {

  Qry = new Query();

  Qry.returnGeometry = true

  Qry.outFields = ["MKTG_TOTAL", "ZO_ZONE"];

  //Create the find parameters

          findParams = new FindParameters();

          findParams.returnGeometry = true;

          findParams.layerIds = [1];

          findParams.searchFields = ["ZO_ZONE", "MKTG_CON_1"];

          findParams.outSpatialReference = map.spatialReference;

          console.log("find sr: ", findParams.outSpatialReference);





        function doFind() {


            dom.byId("owner").value = dom.byId("owner").defaultValue;

          //Set the search text to the value in the box

          findParams.searchText = dom.byId("ZoneTyp").value;

          findTask.execute(findParams, showResults);



  function doFind1() {


       dom.byId("ZoneTyp").value = dom.byId("ZoneTyp").defaultValue;

          //Set the search text to the value in the box

          findParams.searchText = dom.byId("owner").value;

          findTask.execute(findParams, showResults);



  function QryExe() { //getting error on this function....)

       // var val = dom.byId("acres").value;


        Qry.where =  "ZO_ZONE LIKE 'PDOP'";

        //Query.where = "ZO_ZONE LIKE '%" +  dojo.byId('acres').value + "%'";





        function showResults(results) {

          //This function works with an array of FindResult that the task returns;

          var symbol = new SimpleFillSymbol(


            new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 102, 204]), 3),

            new Color([0, 102, 204, 0.5])




          //create array of attributes

          var items =, function (result) {

            var graphic = result.feature;




            return result.feature.attributes;




          //Create data object to be used in store

          var data = {

            identifier : "PA_MCPI", //This field needs to have unique values

            label : "PARCELID", //Name field for display. Not pertinent to a grid but may be used elsewhere.

            items : items




          //Create data store and bind to grid.

          store = new ItemFileReadStore({data : data});

          var grid = registry.byId("grid");


          grid.on("rowclick", onRowClickHandler);

          //Zoom back to the initial map extent

          map.centerAndZoom(center, zoom);




        //Zoom to the parcel when the user clicks a row

        function onRowClickHandler(evt) {


          var clickedTaxLotId = evt.grid.getItem(evt.rowIndex).PA_MCPI;

          var selectedTaxLot = arrayUtils.filter(, function (graphic) {

    return ((graphic.attributes) && graphic.attributes.PA_MCPI === clickedTaxLotId);







          if ( selectedTaxLot.length ) {

            map.setExtent(selectedTaxLot[0].geometry.getExtent(), true);