I've got a model that just copies features from one feature class and appends them to another. If a user supplies a string variable in the NewName field, it overwrites the values for the Name field in the feature class. However, I can't get this working in the code block.
def calcName(Name, NewName):
if len(NewName) == 0: #Meaning the user did not enter a variable here
return Name
else:
return NewName
calcName(!Name!, '%NewName%')
This results in the field always being changed to '%NewName%' within the field. It doesn't matter what the string is, it always returns '%NewName%'. I can type potato in the NewName parameter and it will return '%NewName%'.
