<?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 How to correctly apply a filter when creating a joined view layer with addToDefinition in arcpy? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-correctly-apply-a-filter-when-creating-a/m-p/1654605#M99349</link>
    <description>&lt;P&gt;I’m trying to use addToDefinition in arcpy to create a view layer with a filter.&lt;/P&gt;&lt;P&gt;At first, I tried something like this, using &lt;A href="https://developers.arcgis.com/rest/services-reference/online/add-to-definition-feature-service/#advanced-views" target="_blank" rel="noopener"&gt;Add to Definition (Feature Service) | ArcGIS REST APIs | Esri Developer&lt;/A&gt;&amp;nbsp;as a reference:&lt;/P&gt;&lt;P&gt;"filter": "&amp;lt;filter&amp;gt;&lt;/P&gt;&lt;P&gt;But this generated an error: “A database error has occurred.”&lt;/P&gt;&lt;P&gt;Then, by checking the server logs, I noticed the error “not a JSON object”, so I understood that I needed to pass a dictionary instead.&lt;/P&gt;&lt;P&gt;So I tried something along the lines of:&lt;/P&gt;&lt;P&gt;"filter": {&lt;BR /&gt;"where": "xxx",&lt;BR /&gt;"field_name": "yyy"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;and also:&lt;BR /&gt;"viewDefinitionQuery": {&lt;BR /&gt;"where": "field_name = 'some_value'"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;This time I didn’t get any errors, and the view was created successfully — but the filter was not applied.&lt;/P&gt;&lt;P&gt;My question is:&lt;BR /&gt;What is the correct way to create a view layer with addToDefinition in arcpy and apply a filter at the same time?&lt;/P&gt;&lt;P&gt;Any guidance or working example would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Oct 2025 20:02:37 GMT</pubDate>
    <dc:creator>JuanTomásMartinez17</dc:creator>
    <dc:date>2025-10-01T20:02:37Z</dc:date>
    <item>
      <title>How to correctly apply a filter when creating a joined view layer with addToDefinition in arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-correctly-apply-a-filter-when-creating-a/m-p/1654605#M99349</link>
      <description>&lt;P&gt;I’m trying to use addToDefinition in arcpy to create a view layer with a filter.&lt;/P&gt;&lt;P&gt;At first, I tried something like this, using &lt;A href="https://developers.arcgis.com/rest/services-reference/online/add-to-definition-feature-service/#advanced-views" target="_blank" rel="noopener"&gt;Add to Definition (Feature Service) | ArcGIS REST APIs | Esri Developer&lt;/A&gt;&amp;nbsp;as a reference:&lt;/P&gt;&lt;P&gt;"filter": "&amp;lt;filter&amp;gt;&lt;/P&gt;&lt;P&gt;But this generated an error: “A database error has occurred.”&lt;/P&gt;&lt;P&gt;Then, by checking the server logs, I noticed the error “not a JSON object”, so I understood that I needed to pass a dictionary instead.&lt;/P&gt;&lt;P&gt;So I tried something along the lines of:&lt;/P&gt;&lt;P&gt;"filter": {&lt;BR /&gt;"where": "xxx",&lt;BR /&gt;"field_name": "yyy"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;and also:&lt;BR /&gt;"viewDefinitionQuery": {&lt;BR /&gt;"where": "field_name = 'some_value'"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;This time I didn’t get any errors, and the view was created successfully — but the filter was not applied.&lt;/P&gt;&lt;P&gt;My question is:&lt;BR /&gt;What is the correct way to create a view layer with addToDefinition in arcpy and apply a filter at the same time?&lt;/P&gt;&lt;P&gt;Any guidance or working example would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Oct 2025 20:02:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-correctly-apply-a-filter-when-creating-a/m-p/1654605#M99349</guid>
      <dc:creator>JuanTomásMartinez17</dc:creator>
      <dc:date>2025-10-01T20:02:37Z</dc:date>
    </item>
  </channel>
</rss>

