<?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: Code - Does Feature Class have attachments in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263034#M8438</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633156"&gt;@kapalczynski&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Same principal applies for AGOL/Portal, you can get the feature service item id from the URL when you click into the service item in Portal. Just copy the id into the script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Clubdebambos_0-1677681758032.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64026iA7F0419DDF433D1C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Clubdebambos_0-1677681758032.png" alt="Clubdebambos_0-1677681758032.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;GIS("home") will access AGOL or Portal depending on which one you are logged into last in ArcGIS Pro.&lt;/P&gt;&lt;P&gt;You could change this to use full parameters&lt;/P&gt;&lt;LI-CODE lang="python"&gt;agol = GIS("PORTAL_URL", "PORTAL_USERNAME", "PORTAL_PASSWORD")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Mar 2023 14:46:45 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2023-03-01T14:46:45Z</dc:date>
    <item>
      <title>Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1262994#M8435</link>
      <description>&lt;P&gt;Looking for some code that would verify if a Feature Layer has Attachments...&lt;/P&gt;&lt;P&gt;I can check using the describe for many things like if Tracking is Enabled but not sure for attachments I do not see that as a child of DESCRIBE&lt;/P&gt;&lt;P&gt;Thoughts...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;desc1 = arcpy.Describe(LayerA)
hasEditorTracking = desc1.editorTrackingEnabled
print(hasEditorTracking )&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;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 13:41:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1262994#M8435</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-03-01T13:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1262999#M8436</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633156"&gt;@kapalczynski&lt;/a&gt;&lt;/P&gt;&lt;P&gt;See commented code below for checking if a layer has attachments enabled for a Feature Layer.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

## connect to AGOL
agol = GIS("home")

## access Feature Service Item using Item ID
item = agol.content.get("INSERT_ITEM_ID")

## iterate through layers and print name and if hasAttachments (True or False)
for lyr in item.layers:
    print(lyr.properties.name)
    print(lyr.properties.hasAttachments)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 13:58:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1262999#M8436</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-03-01T13:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263020#M8437</link>
      <description>&lt;P&gt;OK I should have been a bit more specific... this data resides on our oracle server and is publish to portal.&amp;nbsp; I would assume that it would change the syntax a bit?&lt;/P&gt;&lt;P&gt;Where this is referencing AGOL&lt;/P&gt;&lt;PRE&gt;item = agol.content.get("INSERT_ITEM_ID")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 14:25:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263020#M8437</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-03-01T14:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263034#M8438</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633156"&gt;@kapalczynski&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Same principal applies for AGOL/Portal, you can get the feature service item id from the URL when you click into the service item in Portal. Just copy the id into the script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Clubdebambos_0-1677681758032.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64026iA7F0419DDF433D1C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Clubdebambos_0-1677681758032.png" alt="Clubdebambos_0-1677681758032.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;GIS("home") will access AGOL or Portal depending on which one you are logged into last in ArcGIS Pro.&lt;/P&gt;&lt;P&gt;You could change this to use full parameters&lt;/P&gt;&lt;LI-CODE lang="python"&gt;agol = GIS("PORTAL_URL", "PORTAL_USERNAME", "PORTAL_PASSWORD")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 14:46:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263034#M8438</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-03-01T14:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263054#M8439</link>
      <description>&lt;P&gt;You can also use ArcPy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

## Path to Feature Class in SDE/GDB
fc = r"path\to\fc"

## get a describe dictionary
desc = arcpy.da.Describe(fc)

## if there is an ATTACHREL relationship class print the name of it.
## this would hint that attachments are enabled
for relclass_name in desc["relationshipClassNames"]:
    if "ATTACHREL" in relclass_name:
        print(relclass_name)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 01 Mar 2023 15:04:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263054#M8439</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-03-01T15:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263072#M8441</link>
      <description>&lt;P&gt;Thats what I was looking for&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wont know the ID unless I look for it... need this to be within Python....&lt;/P&gt;&lt;P&gt;THANK YOU BOTH for your thoughts...&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 01 Mar 2023 15:26:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263072#M8441</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-03-01T15:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263083#M8442</link>
      <description>&lt;P&gt;I do get this error though:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:/Users/Ja/Desktop/GIS_projects/Land Use Project Folder/PythonScripts/LUPS_Data_TEST_to_UAT_DESCRIBE.py", line 47, in &amp;lt;module&amp;gt;&lt;BR /&gt;for relclass_name in desc1["relationshipClassNames"]:&lt;BR /&gt;TypeError: 'geoprocessing describe data object' object is not subscriptable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;LayerA_Tst = "Database Connections\\TEST@gis_data.sde\\GIS_DATA.SDE_TEST"
desc1 = arcpy.Describe(LayerA_Tst)

for relclass_name in desc1["relationshipClassNames"]:
    if "ATTACHREL" in relclass_name:
        print(relclass_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 15:42:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263083#M8442</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-03-01T15:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263095#M8443</link>
      <description>&lt;P&gt;I'm using the data access module in mine to access describe as a dictionary rather than a describe object. Change to this line below.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;desc1 = arcpy.da.Describe(LayerA_Tst)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 01 Mar 2023 15:47:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263095#M8443</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-03-01T15:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263099#M8444</link>
      <description>&lt;P&gt;Thanks again... missed that...&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 15:51:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263099#M8444</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-03-01T15:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263111#M8445</link>
      <description>&lt;P&gt;question:&amp;nbsp; If there are no Attachments there it does nothing... I cant seem to trap if they are there if they are not...&lt;/P&gt;&lt;P&gt;If there are NO attachments I don't get True OR False&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;for relclass_name in desc1a["relationshipClassNames"]:
    if "ATTACHREL" in relclass_name:
        print("True")
    else:
        print("False")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT:&amp;nbsp; I guess I can just play with a variable and change it from True to false and report on that.... I think I can get it to work.... albeit clumsy..&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 16:26:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263111#M8445</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-03-01T16:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263115#M8447</link>
      <description>&lt;P&gt;I just did this with a couple variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;hasAttachments1 = "FALSE"
hasAttachments2 = "FALSE"

for relclass_name in desc1a["relationshipClassNames"]:
    if "ATTACHREL" in relclass_name:
        hasAttachments1 = "True - " + str(relclass_name)
        
for relclass_name in desc2a["relationshipClassNames"]:
    if "ATTACHREL" in relclass_name:
        hasAttachments2 = "True - " + str(relclass_name)

print("---Attachments: " + hasAttachments1)
print("---Attachments: " + hasAttachments2)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 01 Mar 2023 16:28:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263115#M8447</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-03-01T16:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263433#M8451</link>
      <description>&lt;LI-CODE lang="python"&gt;import arcpy

## Path to Feature Class in SDE/GDB
fc = r"path\to\fc"

## get a describe dictionary
desc = arcpy.da.Describe(fc)

## if there are no relationships classes then no attachments
if not desc["relationshipClassNames"]:
    print("FALSE")
## if there are relationship classes
else:
    ## check if there is an ATTACHREL relationship class
    if [relclass_name for relclass_name in desc["relationshipClassNames"] if "ATTACHREL" in relclass_name]:
        print("TRUE")
    ## otherwise no attachments
    else:
        print("FALSE")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 02 Mar 2023 09:32:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1263433#M8451</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-03-02T09:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Code - Does Feature Class have attachments</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1576042#M11066</link>
      <description>&lt;P&gt;Here's another way to achieve this using one line.&lt;/P&gt;&lt;P&gt;Using the Data Access describe ensures we have a dictionary and can use the 'get' method to provide a fallback of an empty list if the relationshipClassNames key doesn't exist.&lt;/P&gt;&lt;P&gt;The code iterates over the strings in the relationshipClassNames list and checks if any match the baseName of the featureclass with '__ATTACHREL' at the end which indicates attachments are enabled.&lt;/P&gt;&lt;P&gt;The python 'any' keyword returns true if any of the strings match and false if none do.&lt;/P&gt;&lt;P&gt;This should therefore return true if there are attachments and false if not. It's essentially the same as previously suggested code, but some people prefer one liners and some prefer multiline if/else statements as more readable. Take your pick&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;desc = arcpy.da.Describe(feature_class)
hasAttachments = any(value == f'{desc.get('baseName', '||')}__ATTACHREL' for value in desc.get('relationshipClassNames', []))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 22:58:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/code-does-feature-class-have-attachments/m-p/1576042#M11066</guid>
      <dc:creator>PaulHaakma</dc:creator>
      <dc:date>2025-01-15T22:58:45Z</dc:date>
    </item>
  </channel>
</rss>

