here is some code that runs in an mxd from the tool box, the user chooses the layer to do a search on, the script tests the layer to see if the field to do the search on exists then tests the layer to see if it is from a file geodatabase or an sde database by checking wether the layer is versioned so that the field will have quotation marks around it in the selection query for a file geodatabase feature classthe script works, but is there a better way to test for these things?## Get the selection layer
SelLayer = arcpy.GetParameterAsText(0)
## Check to see if the selection layer has a FIELD field
try: Afld
except NameError:
pass
else:
del Afld
for flds in arcpy.ListFields(SelLayer, "FIELD"):
Afld = True
try: Afld
except NameError:
arcpy.AddMessage(r"!! There is no FIELD field in %s, please select a layer with an FIELD field !!"%(SelLayer))
quit()
else:
del Afld
## set the ALTKEY field based on the layer type
check = arcpy.Describe(SelLayer)
if check.isVersioned:
FLD = "FIELD"
else:
FLD = '"FIELD"'