<?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 QueryTask Distinct Geometry query in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-distinct-geometry-query/m-p/1034560#M71987</link>
    <description>&lt;P&gt;Hi, in my application, I'm using the ArcGIS for JavaScript, version 3.35.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In JavaScript, I've created a &lt;STRONG&gt;QueryTask&lt;/STRONG&gt; to find all of the features in a layer which are contained in the specified geometry.&amp;nbsp; This will often exceed 1,000 features as indicated in the exceededTransferLimit property of the resultant FeatureSet.&amp;nbsp; I have a loop in JavaScript, which loops over the results and adds the unique values to an array.&lt;/P&gt;&lt;P&gt;Is there a way to set the &lt;STRONG&gt;returnDistinctValues&amp;nbsp;&lt;/STRONG&gt;property of the Query while also providing the &lt;STRONG&gt;geometry&lt;/STRONG&gt;?&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we set returnDistinctValues to true, the query does not return any features.&amp;nbsp; If using Distinct is possible, we could do the processing on the server instead of on the client.&amp;nbsp; Note: The data is in a file geodatabase.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let myArray = [];
const queryTask = new QueryTask(url);
const query = new Query();
query.geometry = geometry;
query.spatialRelationship = Query.SPATIAL_REL_CONTAINS;
query.outFields = ["SOMEVALUE"];
//query.returnDistinctValues = true; // this returns no results when true
query.distance = 10;
query.units = "feet";
queryTask.execute(query,
    function(featureSet) {
	$.each(featureSet.features,
		function(index, feature) {
			const someValue = 
                            feature.attributes["SOMEVALUE"];
            if (someValue &amp;amp;&amp;amp;
			  parseInt(someValue) &amp;gt;= 0) {
			if (myArray.indexOf(someValue) === -1) {										 
                              myArray.push(someValue);
			}
	     }
		});
		resolve(myArray));
	},
	function(err) {
		reject(err);
	});&lt;/LI-CODE&gt;&lt;P&gt;The FeatureLayer that we're querying has the supportsAdvancedQueries set to true.&amp;nbsp;&amp;nbsp;ESRI’s documentation says Distinct is supported if the layer has the supportsAdvancedQueries option set to true.&lt;/P&gt;&lt;P class="xmsonormal"&gt;&lt;A href="https://developers.arcgis.com/javascript/3/jsapi/query-amd.html#returndistinctvalues" target="_blank"&gt;https://developers.arcgis.com/javascript/3/jsapi/query-amd.html#returndistinctvalues&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks for any insight or assistance.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Mar 2021 17:38:05 GMT</pubDate>
    <dc:creator>AndyWhitaker1</dc:creator>
    <dc:date>2021-03-09T17:38:05Z</dc:date>
    <item>
      <title>QueryTask Distinct Geometry query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-distinct-geometry-query/m-p/1034560#M71987</link>
      <description>&lt;P&gt;Hi, in my application, I'm using the ArcGIS for JavaScript, version 3.35.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In JavaScript, I've created a &lt;STRONG&gt;QueryTask&lt;/STRONG&gt; to find all of the features in a layer which are contained in the specified geometry.&amp;nbsp; This will often exceed 1,000 features as indicated in the exceededTransferLimit property of the resultant FeatureSet.&amp;nbsp; I have a loop in JavaScript, which loops over the results and adds the unique values to an array.&lt;/P&gt;&lt;P&gt;Is there a way to set the &lt;STRONG&gt;returnDistinctValues&amp;nbsp;&lt;/STRONG&gt;property of the Query while also providing the &lt;STRONG&gt;geometry&lt;/STRONG&gt;?&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we set returnDistinctValues to true, the query does not return any features.&amp;nbsp; If using Distinct is possible, we could do the processing on the server instead of on the client.&amp;nbsp; Note: The data is in a file geodatabase.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let myArray = [];
const queryTask = new QueryTask(url);
const query = new Query();
query.geometry = geometry;
query.spatialRelationship = Query.SPATIAL_REL_CONTAINS;
query.outFields = ["SOMEVALUE"];
//query.returnDistinctValues = true; // this returns no results when true
query.distance = 10;
query.units = "feet";
queryTask.execute(query,
    function(featureSet) {
	$.each(featureSet.features,
		function(index, feature) {
			const someValue = 
                            feature.attributes["SOMEVALUE"];
            if (someValue &amp;amp;&amp;amp;
			  parseInt(someValue) &amp;gt;= 0) {
			if (myArray.indexOf(someValue) === -1) {										 
                              myArray.push(someValue);
			}
	     }
		});
		resolve(myArray));
	},
	function(err) {
		reject(err);
	});&lt;/LI-CODE&gt;&lt;P&gt;The FeatureLayer that we're querying has the supportsAdvancedQueries set to true.&amp;nbsp;&amp;nbsp;ESRI’s documentation says Distinct is supported if the layer has the supportsAdvancedQueries option set to true.&lt;/P&gt;&lt;P class="xmsonormal"&gt;&lt;A href="https://developers.arcgis.com/javascript/3/jsapi/query-amd.html#returndistinctvalues" target="_blank"&gt;https://developers.arcgis.com/javascript/3/jsapi/query-amd.html#returndistinctvalues&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks for any insight or assistance.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 17:38:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-distinct-geometry-query/m-p/1034560#M71987</guid>
      <dc:creator>AndyWhitaker1</dc:creator>
      <dc:date>2021-03-09T17:38:05Z</dc:date>
    </item>
  </channel>
</rss>

