YLiAustin

How to call a querytask.execute in a event

Discussion created by YLiAustin on Jun 13, 2014
Latest reply on Jun 17, 2014 by JUihlein-esristaff
My map needs to be updated every 15 minutes. I need to query to get new data time from the update. So i put a query function in "update-end" event. However the display function is never called. please help. Thanks

system info: ArcGIS Server 10.2.1; Javascript API 3.9

var l;

            if (layer.type == 'dynamic')
            {
                l = new esri.layers.ArcGISDynamicMapServiceLayer(layer.url, layer.options);

                l.on("update-end", function (evt)
                {
                    refreshcount++;
                    var timequery = new query();
                    alert("fewsquerytask==" + config.fewsQueryTaskService);
                    var queryTask = new QueryTask(config.fewsQueryTaskService);
                    timequery.returnGeometry = false;
                    timequery.outFields = ["PACKET_DATE_TIME"];
                    timequery.where = "PACKET_DATE_TIME is not null";

                    queryTask.execute(querytime, showTime);

                    function showTime(listfeatures)
                    {
                        alter("inside showTime");
                        var feature = listfeatures.features[0];
                        var value = feature.attributes["PACKET_DATE_TIME"];
                        alert("packet value==" + value);
                        dom.byId("packettime").innerHTML = "Refresh:  "+refreshcount+"  Packet Time:  " + value;
                    }                       

                  
                });

Outcomes