Unique Customer Number

Hi Community

I am interested in finding out how to generate a unique Customer Number when creating a new customer. This very important when you have, for example - a large number of people who share the same name and your agents have to go through all the names to answer queries. This applies to Suppliers (Supplier Number) too. In the Employees documents for examplyee the system creates a unique employee number for each employee that gets loaded.

I am not sure if this is an out of the box functionality provided by ERPNext as i have tried using the “Series” functionality in vain.I know that i may have to created a custom field to achieve that but if i do then how will do i create a unique field that is automatically generated when saving a record? If you need any clarification please do ask.

Thank you very much.

You can define custom autoname method in your hooks.py

1 Like

Hi jof2jc

Thank you for the reply. I am still a novice in this platform. Please guide on how i would go about doing that. Thanks again

Hi @Sbhekuza

You can setup unique Customer Number when creating a new customer at /desk#Form/Selling Settings

Here are formal docs with a live action video example! https://erpnext.org/docs/user/manual/en/setting-up/settings/naming-series


In your custom app’s hooks.py declare doc event like this:

doc_events = {
    "Customer": {
	"autoname": "custom1.custom1.custom1.customer_autoname"

Thank you very much. This helped me.

1 Like

Thank you very much clarkej. Much appreciated.