I have a dataset for utility work permits and we recently started tracking applicant email addresses so I am looking for help in writing a script for the Code Block field to do the bulk of the work of populating emails for the applicants that have more than one permit. The logic behind this would essentially be:
if ContactName = Joe Schmo
return email@example.com in the email field
elif ContactName = Jane Doe
return firstname.lastname@example.org in the email field
then if ContactName = anything else
I would like to add more cases to cover more bases, but only spelt out those 3 for brevity. I have searched and searched already for previous examples and have tried to write several bits to try to accomplish this but to no avail. Here are the two bits I have tried to run and have gotten nowhere with both:
Email = Reclass(!Email!)
fieldName = "Email"
expression = "getClass(!ContactName!, Email!)"
codeblock = """def getClass(ContactName, Email):
if ContactName == 'Joe Schmo':
arcpy.CalculateField_management(out_feature_class, fieldName, expression, "PYTHON_9.3", codeblock)
I am using ArcPro, so I know the version of Python that it uses is different than ArcMap's, but that is literally all I know. I do not know what the differences in the syntaxes are and I do not have experience with any syntax or calling functions with Python or any scripting language. I have next to no background in scripting, so any help on how to set this up in the Code Block would be greatly appreciated.