I have a model which iterates through a GDB, populating the same attribute field in every feature class with a parameter value. In this way I can mark all FC's in the geodatabase as to what project they are a part of.
However, sometimes a GDB contains FC's which are migrated from other GDB projects, with the attribute already populated with a value designating it as part of the other project. Currently my model stomps on this value and overwrites it with the new project code, whereas I want to retain the existing information.
I would like to have the model evaluate the field for the record it is working with, and if the field is not empty, to leave the field alone and move to the next record. However if the field is then it should write the new project code to the field and move on.
I've looked into a bit of the if/then questions and answers but have not found a simple way to detect if a field is empty or not, and if not, how to skip it?
I am now trying to write some Python to handle it and have the following, however I am not sure how to get the parameter value from the user entry in the model (ie. UserInputFromModelParameter), or what command to send to make the script skip to the next record if the script is true.
# set up variables def BlockName: def IgnoreField: # set block name from user inpuit BlockName = [UserInputFromModelParameter] # set values to watch for IgnoreField = [NULL, ""] # evaluate the field if [BlockID] == IgnoreField MoveToNextRecord(); else: [BlockID] = BlockName();