EDIT: I was able to solve the problem with the dictionary approach suggested by @BERA. However, I still don't get why it does not work with the CalculateField method.
I'm trying to calculate a field in a joined table in ArcPy. Code snippet below.
The Calculate Field always gives back the error message:
ERROR 000539: Invalid field MAX
When I do the same thing manually one after the other in ArcGIS everything works perfectly well.
poly_riskobj = r"E:\SRRM_Walldorf\Risikoobjekte.gdb\Ro_Mitte" out_stat_table = r"E:\SRRM_Walldorf\Risikoobjekte.gdb\Ro_Mitte_HQ100" arcpy.MakeTableView_management(out_stat_table, "table_view") arcpy.MakeFeatureLayer_management(poly_riskobj, "obj_layer") arcpy.AddJoin_management("obj_layer", "OBJECTID", "table_view", "OBJECTID_1") arcpy.CalculateField_management(poly_riskobj, "WSP_HQ100", "!MAX!")
When I checked the fields with arcpy.ListFields I realized that the joined fields are missing in the poly_riskobj fc I'm refering to in the CalculateField. They only exist in the obj_layer. Which makes sense... So I adapted the CalculateField to
arcpy.CalculateField_management("obj_layer", "WSP_HQ100", "!MAX!")
and saved it with CopyFeatures. Hoewever, when I check the result in ArcGIS the field "WSP_HQ100" is not updated with the MAX values.
I don't know what I'm missing. I read through these posts but could't figuere it out: