import arcpy from arcpy import env env.workspace = r"C:\temp\python\VECTOR.sde" for fc in arcpy.ListFeatureClasses("*"): for field in arcpy.ListFields(fc, "", "GlobalID"): if field.name == "GlobalID": print fc + " contains GlobalIDs" for fd in arcpy.ListDatasets("*"): for fc in arcpy.ListFeatureClasses("*", "", fd): for field in arcpy.ListFields(fc, "", "GlobalID"): if field.name == "GlobalID": print fc + " contains GlobalIDs"
I am wanting to do this as well. Your posted solution does not feel very robust to me because it is based only on the name of the field. I was able to add a GlobalID text field to a fgdb feature class. This would be a false positive in your code. I looked over the field properties for a better solution, but I don't see one. It would be nice to have a function that returns a boolean--something like: hasGlobalID(table/feature class) = True/False.
We want to add global ids to all ersi objects in our database but some have existing global ids.
There is just a function, or really a property: GDB Table properties—ArcPy Functions | ArcGIS Desktop
Properties
Property Explanation Data Type globalIDFieldName (Read Only)The name of the GlobalID field.
String hasGlobalID (Read Only)Indicates whether the table has a GlobalID field.
Boolean
Thanks Joshua!