<?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 Cannot delete features in hosted feature layer using ArcGIS API for Python in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055787#M6023</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have a hosted Feature Layer on AGOL with 3 layers.&lt;/P&gt;&lt;P&gt;When I run following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;gis = GIS("portal", "user", "password")
feature_layer_item = gis.content.get("layer item id")

for layer_id in [0, 1, 2]:
    layer = feature_layer_item.layers[layer_id]
    result = layer.delete_features(where="1=1")
    logging.info("Delete Result: {}".format(result))

# note: code snippet simplified for question&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is deleted for 2 layers but not the third one, even though it's the same code and a simple where clause.&lt;/P&gt;&lt;P&gt;I get following error which does not help at all:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Delete Result: {'deleteResults': [{'objectId': 1, 'uniqueId': 1, 'globalId': None, 'success': False, 'error': {'code': 1000, 'description': "Incorrect syntax near ')'."}}]}&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Incorrect syntax near ')'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not see an error in the where clause &lt;STRONG&gt;1=1&lt;/STRONG&gt; and it works for the other layers.&lt;/P&gt;&lt;P&gt;There must be something I miss or could this be a bug?&lt;/P&gt;</description>
    <pubDate>Fri, 07 May 2021 18:42:25 GMT</pubDate>
    <dc:creator>Thomas_Z1</dc:creator>
    <dc:date>2021-05-07T18:42:25Z</dc:date>
    <item>
      <title>Cannot delete features in hosted feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055787#M6023</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have a hosted Feature Layer on AGOL with 3 layers.&lt;/P&gt;&lt;P&gt;When I run following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;gis = GIS("portal", "user", "password")
feature_layer_item = gis.content.get("layer item id")

for layer_id in [0, 1, 2]:
    layer = feature_layer_item.layers[layer_id]
    result = layer.delete_features(where="1=1")
    logging.info("Delete Result: {}".format(result))

# note: code snippet simplified for question&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is deleted for 2 layers but not the third one, even though it's the same code and a simple where clause.&lt;/P&gt;&lt;P&gt;I get following error which does not help at all:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Delete Result: {'deleteResults': [{'objectId': 1, 'uniqueId': 1, 'globalId': None, 'success': False, 'error': {'code': 1000, 'description': "Incorrect syntax near ')'."}}]}&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Incorrect syntax near ')'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not see an error in the where clause &lt;STRONG&gt;1=1&lt;/STRONG&gt; and it works for the other layers.&lt;/P&gt;&lt;P&gt;There must be something I miss or could this be a bug?&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 18:42:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055787#M6023</guid>
      <dc:creator>Thomas_Z1</dc:creator>
      <dc:date>2021-05-07T18:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot delete features in hosted feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055803#M6025</link>
      <description>&lt;P&gt;Can you print anything about the layer when you're processing the 3rd layer?&amp;nbsp; Or the raw unformatted result.&amp;nbsp; &amp;nbsp;Seems like it's coming back null.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 18:26:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055803#M6025</guid>
      <dc:creator>DB_PPF</dc:creator>
      <dc:date>2021-05-07T18:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot delete features in hosted feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055807#M6026</link>
      <description>&lt;P&gt;I am able to print a JSON string with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;print(layer.properties)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(unfortunately I cannot post the whole string, there are confidential information, if you know a specific part which should be checked, let me know)&lt;/P&gt;&lt;P&gt;However, the layer is not null. And it's actually the second of three layers. No exception thrown or other errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result of&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;layer.delete_features(where="1=1")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{'deleteResults': [{'objectId': 1, 'uniqueId': 1, 'globalId': None, 'success': False, 'error': {'code': 1000, 'description': "Incorrect syntax near ')'."}}]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's just not making sense.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 18:43:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055807#M6026</guid>
      <dc:creator>Thomas_Z1</dc:creator>
      <dc:date>2021-05-07T18:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot delete features in hosted feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055835#M6027</link>
      <description>&lt;P&gt;Since you are deleting all features, I would recommend using the truncate method.&amp;nbsp; This is much faster.&amp;nbsp; Ex:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;hostedFS= gis.content.get(fsItemId)
fLyr = hostedFS.layers[0]
fLyr.manager.truncate()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 19:25:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055835#M6027</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-05-07T19:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot delete features in hosted feature layer using ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055878#M6028</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;The script above is actually a simplified minimum (non) working example. The issue occurs with this very simple where clause (1=1) and with my actual where clause (fieldName='fieldText').&lt;/P&gt;&lt;P&gt;I am implementing a unit test for an ArcGIS for Python script. I was hoping that I don't have to delete all features so I could run tests asynchronously. But your suggestion could work as a workaround.&lt;/P&gt;&lt;P&gt;It is very strange, why it does work for two of the layers (which have - by the way - exactly the same fields and settings) but not for the third one.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 12:23:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/cannot-delete-features-in-hosted-feature-layer/m-p/1055878#M6028</guid>
      <dc:creator>Thomas_Z1</dc:creator>
      <dc:date>2021-05-10T12:23:42Z</dc:date>
    </item>
  </channel>
</rss>

