When generating a script on a label, you encounter the following error:
TypeError: can't convert AttributeName to string
This error means that the script cannot locate the field name being referenced. This could be due to the field name referenced in the script having the incorrect upper/lower case configuration versus the actual field name in the label, or that the referenced field name in the script does not exist on the label.
In the example below, the script is attempting to replace a value in the "energyCoST" field.
However, the field name in the actual label is named "energyCOST", with an upper case "O".
Either correct the upper/lower case configuration in the field name in the script, change the field name in the script to an actual field name on the label, or add the actual field name into the label itself.