How to use a Naming Series across multiple DocTypes?

How would I go about using a single naming series across multiple DocTypes? I am trying to assign an ID number to all users but the system doesn’t allow me to add customized fields to core DocTypes (the USER DocType). I want a consecutive numbering system for employees, customers, etc.

As for the customisation: If you want to add custom fields to core Doctype, you need to go to → Customize Form → ‘User’ (or any doctype you want to modify) Or go to ‘Custom Field’
From there, you’ll be able to add custom fields.

As for the naming series, I think this is what you want: Customizing naming series

1 Like

Those were the first two things I tried. The user DocType isn’t listed and when I type it in I get “Core DocTypes cannot be customized.” & “Custom Fields cannot be added to core DocTypes.” I am not in developer mode.

That’s not possible, as far as I know.

The only way to achieve what you want is to be in developer mode. Are you hosted by ERPNext? If yes, you need to pass by them first.

I have since tried in developer mode and received the same message. Is there really no number assigned to user accounts?

User accounts are identified by email address.

I’m not concerned with how the system sees user accounts. I have no problem with users logging on with their email address. I’m simply saying that email addresses can change and I also need everyone in the system to have a number attached to them. Most of the users would never even need to know they had this number. For example an email address cannot be typed into a numeric keypad. I also cannot, for privacy reasons, print an email address on a visitors ID pass when they need to get into a building for work or an interview. I am no trying to change the way core works, I’m simply trying to assign a number to everyone.

If that solves your problem, you can add an additional field “Person ID” to User, Employee, Contact, etc. and fill it with your custom logic.

https://erpnext.com/docs/user/manual/en/customize-erpnext/customize-form

That was the first thing I tried. Core DocTypes cannot be customized.

Ah, of course. :man_facepalming:

One more idea: make a new DocType “Person ID” that has a naming like ID-.####### and link fields to User, Contact, etc. Each link field has the unique checkbox set. This way you have an ID number that automatically increments and you can be sure to have only one ID per person.

If you save this DocType to your own app, you can add all the business logic you need.

Also, from within your custom app, you can overwrite the naming of existing doctypes. Provide a function in your app’s hooks.py that returns the name. I’m not sure if it works on core doctypes.

doc_events = {
	"User": {
		"autoname": "my_app.my_module.python_file.python_function",		
	},
	"Contact": {
		"autoname": "my_app.my_module.python_file.python_function",		
	},
}

python_file.py in my_app/my_app/my_module/:

def python_function(doc, method):
    doc.name = # generate person ID 
1 Like

Thank you, what you are suggesting seems like a solution. I’m just not sure of how to link the new doctype to user and contact. Everything I’ve tried hasn’t worked and I couldn’t find any documentation. Does anyone know where this info is?

Am I supposed to be linking fields from User, Contact etc to the new doctype or the other way around? What is the processes in doing so, I’m assuming it isn’t the field type link but I may be wrong as I’m not really sure what is being suggested. If anyone can point me in the correct direction it would be appreciated. Thank you.

It is field type “Link” and you can do it either way. Assign people to an ID or assign an ID to a people.

Scenario 1

Assign an ID to a person.

DocType: Person ID
Naming: ID-.#######
Dashboard: Employee, User, Contact, …

DocType: Employee
Custom Field: Link to Person ID

DocType: User
Custom Field: Link to Person ID

DocType: Contact
Custom Field: Link to Person ID

Scenario 2

Assign a person to an ID.

DocType: Person ID
Naming: ID-.#######
Field: Link to Employee
Field: Link to User
Field: Link to Contact

Thank you for the details. I see what you meant now. I didn’t realize that each user would have to be manually linked to an ID.