I'm trying to create the following in ModelBuilder:
Set input feature class if field1 exists execute the processes in branch1 else add field1 execute the processes in branch2 merge branch
While I have no problem with the processes in the two branches, the
IF check at the start doesn't seem to be working the way I want it to work. I am using this code in the
Calculate Value code block
def ifFieldExists(Input_FC, SUMMARY): import arcpy fields = arcpy.ListFields(Input_FC) for f in fields: if f ==" SUMMARY": return "true" else: return "false"
This is the precondition for
branch1, so if it returns
true, the field exists so
branch1 executes. The other branch's precondition returns the reverse. When I run it on an input that does contain the field, the precondition returns
false instead of
true, so the wrong branch executes.