Thanks Joshua!
There is just a function, or really a property: GDB Table properties—ArcPy Functions | ArcGIS Desktop
PropertiesPropertyExplanationData TypeglobalIDFieldName(Read Only)The name of the GlobalID field.StringhasGlobalID(Read Only)Indicates whether the table has a GlobalID field.Boolean
The name of the GlobalID field.
Indicates whether the table has a GlobalID field.
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.
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"
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.