Hello,
I try to rename the fields of a feature class with their alias name, but I get an error message ERROR 99999.
I use notebook in ArcGIS PRo 2.9.3
Any ideas why?
inFc = "A4_Moorkulisse_2022"
fields = arcpy.ListFields(inFc)
for f in fields:
print (f.name + " - " + f.aliasName)
if f.aliasName in ("OBJECTID", "SHAPE"):
continue
else:
arcpy.management.AlterField(inFc, f.name, f.aliasName, f.aliasName)
print output:
A4_Moorkulisse_2022.OBJECTID - OBJECTID
A4_Moorkulisse_2022.SHAPE - SHAPE
A4_Moorkulisse_2022.A3_Moorkulisse_2022_A2_Moorkulisse_2022_A1_Moorkulisse_2022_SP_R - Ref_Prozent
ExecuteError: ERROR 999999: Beim Werkzeug ist ein unerwarteter Fehler aufgetreten. Wenden Sie sich an den technischen Support von Esri (http://esriurl.com/support), und ziehen Sie die Fehlerhilfe zu Rate, die Informationen zu möglichen Lösungen oder Problemumgehungen enthält.
Fehler beim Ausführen von (AlterField).
Solved! Go to Solution.
You can't have spaces or dashes in the field name.
Ah Ok, thank you for your answer.
But it wasn't me who puts points in the field name, it is caused throught several arcpy.managment.AddJoin and then copy features processes .... so I don't know how to avoid the points?
If I use this it seems to work, convert to string:
arcpy.management.AlterField(inFc, str(f.name), str(f.aliasName), str(f.aliasName))
Thank you JeffK for the hint with the legal field names ...