<?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: Remove attachments in batches from feature service? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1072222#M40926</link>
    <description>&lt;P&gt;Check out the "Remove Attachments" tool in Pro&lt;/P&gt;&lt;P&gt;- select the features you want to remove attachments from and export the selection to a table (uncheck maintain attachments in the environments settings when you do this)&lt;/P&gt;&lt;P&gt;- in the remove attachments tool, use your&amp;nbsp; feature class is the input data and the exported table is the match table&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jun 2021 18:44:52 GMT</pubDate>
    <dc:creator>DebMcIlwrath</dc:creator>
    <dc:date>2021-06-24T18:44:52Z</dc:date>
    <item>
      <title>Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1071639#M40902</link>
      <description>&lt;P&gt;Is it possible to remove all attachments from a large number of selected features in a feature service all at once, but &lt;EM&gt;not&lt;/EM&gt; remove everything?&lt;/P&gt;&lt;P&gt;As far as I know the only way I've been able to remove attachments is by toggling them off and then back on again. You get a pop-up warning that they'll all be removed. What if I just wanted to remove attachments, from, say 100 features, rather than all of them? Is this possible?&lt;/P&gt;&lt;P&gt;(of note, I'm not sure how to do this on a feature class in Pro, either. Definition queries and selecting features doesn't seem to stop all attachments getting removed).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 19:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1071639#M40902</guid>
      <dc:creator>SFM_TravisBott</dc:creator>
      <dc:date>2021-06-23T19:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1072222#M40926</link>
      <description>&lt;P&gt;Check out the "Remove Attachments" tool in Pro&lt;/P&gt;&lt;P&gt;- select the features you want to remove attachments from and export the selection to a table (uncheck maintain attachments in the environments settings when you do this)&lt;/P&gt;&lt;P&gt;- in the remove attachments tool, use your&amp;nbsp; feature class is the input data and the exported table is the match table&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 18:44:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1072222#M40926</guid>
      <dc:creator>DebMcIlwrath</dc:creator>
      <dc:date>2021-06-24T18:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1072315#M40928</link>
      <description>&lt;P&gt;I'll try that method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm familiar with the remove attachments tool, but it was removing all&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;attachments on my test feature classes/feature services, regardless of selection, definition query, or creating a separate layer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The workaround of exporting a separate table is funky but I'll give it a go.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 21:02:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1072315#M40928</guid>
      <dc:creator>SFM_TravisBott</dc:creator>
      <dc:date>2021-06-24T21:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1074972#M41037</link>
      <description>&lt;P&gt;Following up, after testing:&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/320291"&gt;@DebMcIlwrath&lt;/a&gt;&amp;nbsp;'s method works well for a feature class. It does&amp;nbsp;&lt;EM&gt;not&lt;/EM&gt; work for a feature service (which is what I'm trying to accomplish. I received warnings that for the selected records attachments could not be removed, but then they appeared to be removed anyways).&lt;/P&gt;&lt;P&gt;So if you're attempting to selectively remove batches of attachments on a feature service you would have to use a bit of a workaround, like exporting the subset of features, removing their attachments, and then replacing their old version in the feature service.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 21:48:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1074972#M41037</guid>
      <dc:creator>SFM_TravisBott</dc:creator>
      <dc:date>2021-07-01T21:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1150654#M44707</link>
      <description>&lt;P&gt;Did you try any other methods to accomplish this and were they successful?&amp;nbsp; I need to perform this workflow on a very large dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 14:33:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1150654#M44707</guid>
      <dc:creator>MeganEngel</dc:creator>
      <dc:date>2022-03-04T14:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1275796#M51307</link>
      <description>&lt;P&gt;Any news on this topic?&lt;/P&gt;&lt;P&gt;I need to delete attachments from a FS that are eating my credits away...how do I do that?&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Attachments size: 10558.684&amp;nbsp;MB&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 14:42:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1275796#M51307</guid>
      <dc:creator>JoabelBarbieri</dc:creator>
      <dc:date>2023-04-05T14:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1278786#M51473</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is possible using ArcGIS API for Python. You can write a script to query features using an expression and delete the attachments of those selected features only while leaving the rest of attachments in the feature service.&lt;/P&gt;&lt;P&gt;Below is a sample code that you can use. Keep in mind that you need to modify some parameters in the script according to the settings in your own data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You should be careful when deleting attachments, as this operation is permanent and cannot be undone. It's a good practice to make a backup of your data before performing any deletion operations, just in case you accidentally delete something you didn't mean to.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
import arcgis
from arcgis.features import FeatureLayerCollection

gis = GIS("https://www.arcgis.com", "USERNAME", "PASSWORD") #Replace your username and password

featureService = gis.content.get('ITEM_ID')
flayer=featureService.layers[0] #You may need to change layer id from 0 to your own layer number
whereclause = "QUERY_EXPRESSION" #for example "status ='done'" queries features where the value in the "status" field is "done"
for feature in flayer.query(where=whereclause):
    f_oid=feature.attributes.get("OBJECTID") #You need to replace OBJECTID with the name of the objectid field in your dataset.  
    att_list=flayer.attachments.get_list(oid=f_oid)
    if att_list:
        for att in att_list:
            att_id= att['id']
            flayer.attachments.delete(f_oid,att_id)
        print(f"Attachments were deleted for feature {f_oid}")
    else:
        print(f"No attachments found for feature {f_oid}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some documentation that might be helpful for reference:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/guide/using-attachments-with-feature-layers/" target="_blank"&gt;https://developers.arcgis.com/python/guide/using-attachments-with-feature-layers/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html" target="_blank"&gt;https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;MJ&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 14:35:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1278786#M51473</guid>
      <dc:creator>MJBiazar</dc:creator>
      <dc:date>2023-04-14T14:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1294808#M52533</link>
      <description>&lt;P&gt;This worked like a charm!&amp;nbsp; Thanks for sharing.&amp;nbsp; I was able to draft a simple python tool from it with a few dynamic inputs so others can use it within my organization!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-M&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 21:43:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1294808#M52533</guid>
      <dc:creator>MeganEngel</dc:creator>
      <dc:date>2023-05-31T21:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1366072#M56642</link>
      <description>&lt;P&gt;Will running this code on an ArcGIS Online feature service consume credits? If so, how many (e.g. credits per feature or credits per attachment).&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 23:20:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1366072#M56642</guid>
      <dc:creator>heatherdaw</dc:creator>
      <dc:date>2024-01-03T23:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1366432#M56680</link>
      <description>&lt;P&gt;Hey Heath,&lt;/P&gt;&lt;P&gt;As far as i know, this did not consume credits.&amp;nbsp; I ran in it ArcGIS Pro, not AGO notebooks, which may be why.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 19:06:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1366432#M56680</guid>
      <dc:creator>MeganEngel</dc:creator>
      <dc:date>2024-01-04T19:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1366450#M56681</link>
      <description>&lt;P&gt;Thanks Megan. Good to know.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 19:24:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1366450#M56681</guid>
      <dc:creator>heatherdaw</dc:creator>
      <dc:date>2024-01-04T19:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Remove attachments in batches from feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1419019#M59056</link>
      <description>&lt;P&gt;Beauty! Needed to do the same thing and this worked on my first try. Nothing better than that!&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2024 11:34:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/remove-attachments-in-batches-from-feature-service/m-p/1419019#M59056</guid>
      <dc:creator>AdamGaudet</dc:creator>
      <dc:date>2024-05-04T11:34:18Z</dc:date>
    </item>
  </channel>
</rss>

