Looking for some code that would verify if a Feature Layer has Attachments...
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
Thoughts...
desc1 = arcpy.Describe(LayerA)
hasEditorTracking = desc1.editorTrackingEnabled
print(hasEditorTracking )
Solved! Go to Solution.
I just did this with a couple variables:
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)
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")