How to use random_string frappe utils function?

Hello,

I am trying to generate random string and print in system console but what is issue i am not getting it showing below error.

You can’t add the method in the system console.

Please check the documentation.

And also check the video.

@NCP How i can use random_string() in server script?. I have use same code in server script still same. Correct me if i am wrong in order to use this utility.
I want to generate basically 5 digit reference number

def generate_reference_number():
# Generate a random string with digits only and of length 4
reference_number = frappe.utils.random_string(4, ‘0123456789’)
return reference_number

Generate and print the reference number

reference_number = generate_reference_number()
frappe.msgprint(reference_number)

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.