<?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 Issue in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-issue/m-p/1317082#M81923</link>
    <description>&lt;P&gt;The visible property for graphics that come from a FeatureLayer is pretty much meaningless; it's really only useful for graphics in GraphicsLayers.&lt;/P&gt;&lt;P&gt;Your query is also being sent to the service to be executed, and it returns all features that match.&amp;nbsp; Because the conditions of the DE are not included, it therefore returns features 1 and 2 also.&amp;nbsp; If you want the conditions of the DE to be included, you should use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#createQuery" target="_self"&gt;createQuery&lt;/A&gt;, and then modify the where clause with the additional conditions.&lt;/P&gt;&lt;P&gt;Alternatively, if you just want to query the layer on the client side, which will honor your DE, then you can use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures" target="_self"&gt;queryFeatures&lt;/A&gt; on the layer's &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html" target="_self"&gt;LayerView&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Aug 2023 19:02:17 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2023-08-09T19:02:17Z</dc:date>
    <item>
      <title>Definition Expression Issue</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-issue/m-p/1317028#M81912</link>
      <description>&lt;P&gt;Good Day&lt;BR /&gt;&lt;BR /&gt;I'm using &lt;SPAN&gt;"@arcgis/core"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"4.27.6"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I think I found a bug in the querying logic when setting a definition expression (DE).&amp;nbsp; Assume I have a layer and I set the DE to 'a = 1 OR a =2', and two of the X features are now shown.&lt;BR /&gt;&lt;BR /&gt;If I run another query on the map: 'a = 3', and get back a feature / geometry, why is the visible flag still true when the feature isn't visible?&amp;nbsp; Should I be able to use a DE as a first pass filter that's constant, and then on top of that apply more filters using queries?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is a code sample of what I'm doing:&lt;/P&gt;&lt;P&gt;Definition Expression Stage, assume query: 'a = 1 OR a = 2':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this._view?.map?.layers?.forEach((layer) =&amp;gt; {
  if (layer?.type === 'feature' &amp;amp;&amp;amp; !layer?.id.includes('meta-')) {
    layer.definitionExpression = query;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Running the second query, assume mapQuery is: 'a = 3':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const query = {
  where: mapQuery,
  outFields: ['*'],
  returnGeometry: true
}

const visibleFeatures: Graphic[] = [];
this._view.when(() =&amp;gt; {
  this._view.map.layers.forEach((layer) =&amp;gt; {
    if (layer.type === 'feature') {
      layer.queryFeatures(query).then((queryRes) =&amp;gt; {
        queryRes.features?.forEach((feature) =&amp;gt; {
          if (feature.visible) {
            visibleFeatures.push(feature);
          }
        })

        r(visibleFeatures);
       }).catch((error) =&amp;gt; {
         console.log(error);
         j(error);
       })
     }
   })
})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;When I look for anything but a 1 or 2, they aren't visible on the map, so that flag shouldn't be set.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 18:00:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-issue/m-p/1317028#M81912</guid>
      <dc:creator>AndrewMurdoch1</dc:creator>
      <dc:date>2023-08-09T18:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Expression Issue</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-issue/m-p/1317082#M81923</link>
      <description>&lt;P&gt;The visible property for graphics that come from a FeatureLayer is pretty much meaningless; it's really only useful for graphics in GraphicsLayers.&lt;/P&gt;&lt;P&gt;Your query is also being sent to the service to be executed, and it returns all features that match.&amp;nbsp; Because the conditions of the DE are not included, it therefore returns features 1 and 2 also.&amp;nbsp; If you want the conditions of the DE to be included, you should use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#createQuery" target="_self"&gt;createQuery&lt;/A&gt;, and then modify the where clause with the additional conditions.&lt;/P&gt;&lt;P&gt;Alternatively, if you just want to query the layer on the client side, which will honor your DE, then you can use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures" target="_self"&gt;queryFeatures&lt;/A&gt; on the layer's &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html" target="_self"&gt;LayerView&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 19:02:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-issue/m-p/1317082#M81923</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-08-09T19:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Expression Issue</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-issue/m-p/1317106#M81925</link>
      <description>&lt;P&gt;Thanks! That did exactly what I wanted &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 19:45:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/definition-expression-issue/m-p/1317106#M81925</guid>
      <dc:creator>AndrewMurdoch1</dc:creator>
      <dc:date>2023-08-09T19:45:59Z</dc:date>
    </item>
  </channel>
</rss>

