for m in aprx.listMaps():
for lyr in m.listLayers():
if lyr.isFeatureLayer:
arcpy.management.SelectLayerByAttribute(lyr,"NEW_SELECTION", "facilityid = 'AR022'")
else:
print(" " + lyr.name + "no features")
The above code works if all the layers in the map have "facilityid" as a field. How can I put a precheck on that constraint so this just doesn't error out.
I thought this would work but it gives me a 999999 runtime error.
for m in aprx.listMaps():
for lyr in m.listLayers():
if arcpy.ListFields(lyr, 'facilityid'):
print (lyr.name)
else:
print ("Field does not exist " + lyr.name)
any suggestions would be appreciated.
The above syntax works with Feature Classes from a gdb but we are trying to make this work with Feature Services as layers in a pro project map.