I didn't check why it doesn't work, because using this custom function is no good way to implement what you want.
The function is meant to validate data, it's not meant to change data.
Keep also in mind, that custom functions are deprecated and might be removed in future MantisBT versions.
The right way would be to write a plugin that uses event EVENT_UPDATE_BUG_DATA.
Please use Search before posting and read the Manual
thank you for your suggestion, so I'll try to write a custom plugin, but I created an other issue because I don't understand why I can't build my custom plugin, so if you have time, have a look to my other issue please (https://www.mantisbt.org/forums/viewtop ... =3&t=27025)