<?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: Definition Expression on a Query in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-on-a-query/m-p/18235#M1696</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am not sure I understand your question clearly. If you like to query a subset of a layer data, set query.where to limit the result based on the attribute values. That's about the equivalent of definition expression if using Query. If you do need to use the real definition expression as used in ArcMap, create a FeatureLayer for the layer you like to query, and then set definition expression like the below sample:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require(["esri/layers/FeatureLayer", ...], function(FeatureLayer, ...) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var featureLayer = new FeatureLayer("rest/url/of/the/layer",{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mode: FeatureLayer.MODE_SELECTION,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields: ["*"]
&amp;nbsp;&amp;nbsp;&amp;nbsp; }); 
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.setDefinitionExpression("STATE_NAME = 'South Carolina'");
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can further query against the featureLayer using featureLayer.queryFeatures. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope it helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 20:44:13 GMT</pubDate>
    <dc:creator>JasonZou</dc:creator>
    <dc:date>2021-12-10T20:44:13Z</dc:date>
    <item>
      <title>Definition Expression on a Query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-on-a-query/m-p/18233#M1694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does anyone one know of a way to set a definition expression on a query? I have about 4,000 records in my service but I want to limit all queries to about 1,000 of those records.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Sep 2013 19:55:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-on-a-query/m-p/18233#M1694</guid>
      <dc:creator>KennethRichards</dc:creator>
      <dc:date>2013-09-16T19:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Expression on a Query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-on-a-query/m-p/18234#M1695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Does anyone one know of a way to set a definition expression on a query? I have about 4,000 records in my service but I want to limit all queries to about 1,000 of those records.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As far as I know, the only way to set a definition expression on the layer itself and not for individual queries.&amp;nbsp; However, since the definition expression is just SQL, you could just add that into your query where clause.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise, you could create a second FeatureLayer that may not be visible on the map and set the definition expression on that before querying it.&amp;nbsp; Of course, the query would not be reflected on the map, but you would be able to access those features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are simply trying to limit the number of features returned by a query for performance reasons.&amp;nbsp; This is a setting when publishing a service and is usually set to 1000 by default.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Sep 2013 20:05:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-on-a-query/m-p/18234#M1695</guid>
      <dc:creator>BrianBeck</dc:creator>
      <dc:date>2013-09-16T20:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Expression on a Query</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-on-a-query/m-p/18235#M1696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am not sure I understand your question clearly. If you like to query a subset of a layer data, set query.where to limit the result based on the attribute values. That's about the equivalent of definition expression if using Query. If you do need to use the real definition expression as used in ArcMap, create a FeatureLayer for the layer you like to query, and then set definition expression like the below sample:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require(["esri/layers/FeatureLayer", ...], function(FeatureLayer, ...) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var featureLayer = new FeatureLayer("rest/url/of/the/layer",{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mode: FeatureLayer.MODE_SELECTION,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields: ["*"]
&amp;nbsp;&amp;nbsp;&amp;nbsp; }); 
&amp;nbsp;&amp;nbsp;&amp;nbsp; featureLayer.setDefinitionExpression("STATE_NAME = 'South Carolina'");
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can further query against the featureLayer using featureLayer.queryFeatures. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope it helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:44:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-on-a-query/m-p/18235#M1696</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2021-12-10T20:44:13Z</dc:date>
    </item>
  </channel>
</rss>

