How to use random_string frappe utils function?

The server script does not support everything and has some limitations (Certain operations are restricted in safe_exec). I think you need to implement it in your custom app.