ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Auto Generate Item Code if not entered by the user


Is there any way the item code can be auto-generated if not entered by the user?


Try using naming series


How do I do that?


This may help with leads and ideas Please give me autoname() Example


Can we do it from “Customize Form” somehow?


I could not say one way or the other. But one can learn much, browsing this forum to learn from other q&a, exploring the code, and of course from trial and error experimentation…


Try below. It might help.
Go to item list, from the drop down menu go to customize form.
In the row series, in the options give your series option. if you hahe more than one give in the next line.
Select update form.

Go to new item.
you should be able to see the naming series.

Below post might help you Item code generation


It just adds a Series in the Item name. It doesn’t auto generate the item code.
I want it to auto generate the item code if not entered by the user.


This might help you solve your problem.


This code creates the code based on Item Group and Brand. But 2 products having same Item Group and Brand get the same code which isn’t unique. And I get this error.

Also, it won’t be creating any new codes except TA, TB, XX, BA, BB and BX.


I understand your concern, however the given link is a generalized custom script for the same query. You have to write some additional codes within the same like add numbers in ascending order or adding 2 digits at the end by random number select between 1-1000.


In the customize form of item, Uncheck the the field, “mandatory”. Check the field “unique” Item code is normally generated based on the naming series automatically if not given by the user. You may try the method once again that I have given. It worked for me.