I keep getting ERROR 000539 (Invalid field) when trying to use the calculate field on a joined feature class on my python script.
I am trying to create a spatial join between two feature classes, then copy the values from the join table (parcels) into the input table (cofo_geo).
I believe the issue is that the system won't accept the calculate expression for some reason, even though it worked flawlessly when I did it in ArcPro. I have tried doing the expression in Arcade and got the same result.
Here is a subset of my script for reference:
# import libraries
import arcpy
arcpy.env.workspace = #path
arcpy.env.overwriteOutput = True
cofo_geo = #path
parcels = #path
# add spatial join
arcpy.analysis.SpatialJoin(cofo_geo, parcels, 'cofo_SJ')
arcpy.management.AddJoin(cofo_geo, 'Permit_Number', 'cofo_SJ', 'Permit_Number')
arcpy.management.CalculateField(cofo_geo, 'Lot', '!cofo_SJ.LOT_1!', 'PYTHON3')
arcpy.management.RemoveJoin(cofo_geo)