2

My aim to display point data from a feature layer on ArcGIS for JS map interface. I am successful doing so in Chrome and Firefox, however when I include date in a where condition of a query execute it through QueryTask.execute function I am running into issues with IE 11. It works fine when hard coded but not when I read start and end date from a control.

More information:

queryTask.execute throws up the error “Error: Failed to execute query.” on Internet Explorer 11 and EDGE but works fine on Chrome and Firefox browsers. The where condition works fine if I do not give date condition at all in the query for IE11, firefox, chrome, etc.

-----------Case 1:--------------------------------

Case 1: Works fine on IE and other browsers when my where condition is hard coded

query1.where="outlier = 0 and timestamp >= '1/24/2016 5:00:00 AM' and timestamp < '1/25/2016 5:00:00 AM'";
queryTask1.execute(query1, function(results1){.............}, function(error){........});

------------------------Case 2:------------------------

Case 2: is not working on IE. However, works well on Chrome and Friefox browsers.

var WhereCoundition = "outlier = 0 and timestamp >= '1/24/2016 5:00:00 AM' and timestamp < '1/25/2016 5:00:00 AM'";
query1.where = WhereCoundition;
queryTask1.execute(query1, function(results1){.............}, function(error){........});
  • 1
    what sort of thing are you querying? because currently this question seems to have no GIS component – Ian Turton Jan 27 '16 at 16:49
  • I am attaining all unique names from the field VZ_Regions for the date range from a feature layer. -------------------------------------------- var queryTask1 = new esri.tasks.QueryTask(arcAddress + "/" + LayerNumber); var query1 = new esri.tasks.Query(); setQueryWhereCondition(query1); query1.outFields = ["VZ_Regions"]; query1.returnDistinctValues = true; query1.returnGeometry = false; queryTask1.execute(query1, function(results1) – NAVEEN anne jaya prakash Jan 27 '16 at 16:52
1

Conversions to the local date and time in Java Script through the function toLocaleDateString() and toLocaleTimeString() has been adding some hidden characters that could not be displayed through an alert box or console. When the application was run on chrome or Firefox browsers performing queryTask.execute() went smooth. However, doing so from an IE or Edge browser throws the error "Failed to execute query". The solution was to get rid of all non-ASCII characters from the date string before performing queryTask.execute(). The example is provided below.

        fromDate = fDate.toLocaleDateString() + " " + fDate.toLocaleTimeString();


        fromDate=fromDate.replace(/[^\x00-\x7F]/g, "");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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