<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cannot get queryTask with query to return expected result in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50251#M4414</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That got it!&amp;nbsp; The only thing I changed was adding in a single quote in front of the value.&amp;nbsp; The correct code looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;query.where = "PhoneNumber="+"'"+dom.byId("number").value+"'";&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Jan 2015 19:06:07 GMT</pubDate>
    <dc:creator>MichelleRogers1</dc:creator>
    <dc:date>2015-01-14T19:06:07Z</dc:date>
    <item>
      <title>Cannot get queryTask with query to return expected result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50244#M4407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working with an existing website that I did most of the code on.&amp;nbsp; It is a Emergency Operations Center website with automatic vehicle tracking as well as history queries.&amp;nbsp; I was able to query the history for the vehicles with no problem, but I am now trying to query the history of the 911 calls and am coming across some issues.&amp;nbsp; Any help is greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code I am working with:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN&gt;window.Calls911HistoricalUrl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://gis10204:6080/arcgis/rest/services/GeoEvent/AVL_911_Historical_WebOut/FeatureServer/0" rel="nofollow noopener noreferrer" target="_blank"&gt;http://gis10204:6080/arcgis/rest/services/GeoEvent/AVL_911_Historical_WebOut/FeatureServer/0&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;
window.Calls911HistoricalOutFields = ["PhoneNumber", "CallType", "TimeStamp"];

registry.byId("execute911bynumber").on("click", execute911bynumber);
&amp;nbsp; function execute911bynumber(){
&amp;nbsp; var queryTask = new QueryTask(window.Calls911HistoricalUrl);
&amp;nbsp; var query = new Query();
&amp;nbsp; query.returnGeometry = false;
&amp;nbsp; query.outFields = window.Calls911HistoricalOutFields;
&amp;nbsp; query.where = "PhoneNumber = " +"'"+number+"'";
&amp;nbsp; queryTask.execute(query, function(results) {
&amp;nbsp; var data = [];
&amp;nbsp; var data = array.map(results.features, function(feature) {
&amp;nbsp; return {
&amp;nbsp; //property names used here match those used when creating the dgrid&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; "Phonenumber": feature.attributes[window.Calls911HistoricalOutFields[0]],&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; "Calltype": feature.attributes[window.Calls911HistoricalOutFields[1]],
&amp;nbsp; "Timereceived": feature.attributes[window.Calls911HistoricalOutFields[2]]
&amp;nbsp; }
&amp;nbsp; });
&amp;nbsp; var memStore = new Memory({ data: data });
&amp;nbsp; //create historical data dgrid
&amp;nbsp; window.grid2 = new (declare([OnDemandGrid, Selection]))({
&amp;nbsp; bufferRows: Infinity,
&amp;nbsp; store:memStore,
&amp;nbsp; maxRowsPerPage: 5000,
&amp;nbsp; columns: {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; "Phonenumber": "Phone Number",
&amp;nbsp; "Calltype": "Call Type",
&amp;nbsp; "Timereceived": {"label": "Time Received", "formatter": formatTimestamp}
&amp;nbsp; },
&amp;nbsp; loadingMessage: "Loading data...",
&amp;nbsp; noDataMessage: "No records found."
&amp;nbsp; }, "grid2");
&amp;nbsp; grid2.set("sort", [{attribute:"Timereceived", descending:true}]);
&amp;nbsp; });
&amp;nbsp; grid2.setStore();
&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The html code is as follows:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;div data-dojo-type="dijit/layout/ContentPane" id="911historyPane"
&amp;nbsp; data-dojo-props="title:'911 History'" style="background-color:#bee8ff;"&amp;gt;
&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp; Phone Number: &amp;lt;input type="text" id="number" size="20"&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp; Start Date &amp;amp; Time: &amp;lt;input id="911date" type="text" size="20"&amp;gt;&amp;lt;a href="javascript:NewCal('911date', 'mmddyyyy')"&amp;gt;&amp;lt;img src="images/cal.gif" width="18" height="18" border="0"&amp;gt;&amp;lt;/a&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp; End Date &amp;amp; Time: &amp;lt;input id="911date2" type="text" size="20"&amp;gt;&amp;lt;a href="javascript:NewCal('911date2', 'mmddyyyy')"&amp;gt;&amp;lt;img src="images/cal.gif" width="18" height="18" border="0"&amp;gt;&amp;lt;/a&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp; &amp;lt;button id ="execute911bydate" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" title="Search By Date"&amp;gt;Search By Date
&amp;nbsp; &amp;lt;/button&amp;gt;
&amp;nbsp; &amp;lt;button id ="show911" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" title="Show on Map" &amp;gt;Show on Map
&amp;nbsp; &amp;lt;/button&amp;gt;
&amp;nbsp; &amp;lt;button id ="clear911" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" title="Clear" &amp;gt;Clear History
&amp;nbsp; &amp;lt;/button&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp; &amp;lt;div&amp;gt;
&amp;nbsp; &amp;lt;button id="execute911bynumber" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" title="Search By Number"&amp;gt; Search By Number
&amp;nbsp; &amp;lt;/button&amp;gt;
&amp;nbsp; &amp;lt;button dojotype="dijit.form.Button" id="911historyHelp" title="Help"&amp;gt;
&amp;nbsp; &amp;lt;img src="images/Help.png" width=15px height=15px/&amp;gt;
&amp;nbsp; &amp;lt;/button&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;
&amp;nbsp; &amp;lt;div id="grid2" class="claro"&amp;gt;&amp;lt;/div&amp;gt;
&amp;nbsp; &amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;P&gt;I was able to search on date alone and come up with the correct information, but when I try and search on phone number alone, I am getting no results even though I know that there are at least 5 calls for that phone number.&amp;nbsp; I have also tried using query.text = dom.byId("number").value; but using that throws an error, "unable to complete operation".&amp;nbsp; Again, any help figuring this out is greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Michelle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:56:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50244#M4407</guid>
      <dc:creator>MichelleRogers1</dc:creator>
      <dc:date>2021-12-10T21:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get queryTask with query to return expected result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50245#M4408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michelle,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; What is the field type of your &lt;SPAN class="string"&gt;PhoneNumber? If it is a number and not a text then your SQL should not wrap the number in quotes like you do for text.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 17:51:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50245#M4408</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-01-14T17:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get queryTask with query to return expected result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50246#M4409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The field type for PhoneNumber is a string because it has the dashes included, not just the numbers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 17:54:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50246#M4409</guid>
      <dc:creator>MichelleRogers1</dc:creator>
      <dc:date>2015-01-14T17:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get queryTask with query to return expected result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50247#M4410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you done a&lt;/P&gt;&lt;P&gt;console.info(query.where);&lt;/P&gt;&lt;P&gt;to see what the where clause looks like?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 17:59:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50247#M4410</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-01-14T17:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get queryTask with query to return expected result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50248#M4411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only problem I see here is in the line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;query.where = &lt;SPAN class="string"&gt;"PhoneNumber = "&lt;/SPAN&gt; +&lt;SPAN class="string"&gt;"'"&lt;/SPAN&gt;+number+&lt;SPAN class="string"&gt;"'"&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that I don't see where the variable "number" is declared or assigned a value.&amp;nbsp; Unless you've declared and assigned the value elsewhere, this could be the main issue. Perhaps the following might make a difference:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;query.where = "PhoneNumber = '" + dom.byId("number").value + "'";&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 18:55:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50248#M4411</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2015-01-14T18:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get queryTask with query to return expected result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50249#M4412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what the console log shows when I do a console.info(query.where);&lt;/P&gt;&lt;P&gt;PhoneNumber ='[object HTMLInputElement]'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't see anything wrong with it, but the response that I get is this:&lt;/P&gt;&lt;P&gt;{"objectIdFieldName":"OBJECTID","globalIdFieldName":"","features":[]}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, it is returning an empty set for some reason, even though the query is correct and when I do the query from the rest endpoint, I get 5 records like I am expecting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 18:58:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50249#M4412</guid>
      <dc:creator>MichelleRogers1</dc:creator>
      <dc:date>2015-01-14T18:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get queryTask with query to return expected result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50250#M4413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michelle,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PhoneNumber ='[object HTMLInputElement]' is not a valid SQL Statement. Like Joel posted above try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;query.where = "PhoneNumber = '" + dom.byId("number").value + "'";&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:05:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50250#M4413</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-01-14T19:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get queryTask with query to return expected result</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50251#M4414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That got it!&amp;nbsp; The only thing I changed was adding in a single quote in front of the value.&amp;nbsp; The correct code looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;query.where = "PhoneNumber="+"'"+dom.byId("number").value+"'";&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:06:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-querytask-with-query-to-return-expected/m-p/50251#M4414</guid>
      <dc:creator>MichelleRogers1</dc:creator>
      <dc:date>2015-01-14T19:06:07Z</dc:date>
    </item>
  </channel>
</rss>

