Item Naming suggestions

I am looking at the best way to implement Item name Nomenclature. Essentially I am looking for a nomenclature as follows
X will be a hardcoded string
ABCD should be fetched from a custom field on the Item form
NNNNN is a rolling 5 digit no. regardless of what ABCD represents.

Forgot to add this is an instance hosted on Frappe Cloud

Let me know if anybody has implemented this successfully.

1 Like

Managed to implement this. Reach out if anyone is interested.

Hi, would be interested to hear how you achieved this.

Yes interested

My apologies as I was away from the office for quite a long. Here’s what I did.
Welcome any critique to make this better. The following does not work (I believe) when importing items through Data Imports, but I saw some forum messages that should address this.
Goal was to get a nomenclature E-ABCD-NNNNN

  1. In Stock Settings set the item Naming By “Item Code’.
  2. Set the Item Code as Unique to avoid duplicates.
  3. First 3 characters of the ABCD part of the Nomenclature were required from the Item group
  4. The 4th character of the ABCD nomenclature was required from a custom field in the Item form. This field was set as mandatory.
  5. The Item code was constructed using a Client Script (see below)

let curItemCount = 0;

frappe.ui.form.on(‘Item’, {
// frm passed as the first parameter
onload(frm) {
frappe.db.count(‘Item’, {
}).then(count => {
curItemCount = count;
curItemCount = curItemCount.toString().padStart(5,0);

cur_frm.cscript.custom_validate = function(doc) {
doc.item_code = “E-”;
let custom_code = “”;
let item_grp = doc.item_group;
let cCode = item_grp.substring(0,3);
let mounting_type = doc.mounting;
let mtype = mounting_type.substring(0,1);
custom_code = cCode.toUpperCase() + mtype.toUpperCase();

doc.item_code += custom_code;
doc.item_code += "-";
doc.item_code += curItemCount;


Correct me if I am wrong, item sequence is cross ABCD right, it’s not ABCD combination specific.

If you mean the last 5 digits (i.e. NNNNN) is a rolling sequence across the Item Master in ERPNext and the Nomenclature does not care how the ABCD is constructed - then your understanding is correct. Just to illustrate, Let’s say I am adding two items to the Item Master, and let’s say the ABCD part si derived as INTN and CAPS respectively. Then the Item code this method will generate will be E-INTN-00001 and E-CAPS-00002 and subsequent items created will have the trailing suffix 00003, 00004, and so on.
Hope that clarifies.

Thx for the clarification, can we make a proper sequence for each ABCD part, like ABCD00001, 00002… then CAPS00001, 00002,and so on, that means you have to get last seq+1 for each ABCD part.

Yes, you can. Suggested steps are

  1. Set the Item Naming method to Naming Series in Stock settings.
  2. Add a custom field in the item Form, let’s say internal_code.
  3. Use part of the above client script to construct and store the result in the custom field internal_code (i.e. the ABCD part)
  4. In the Naming series for Item include the custom field internal_code as a field with {} brackets. There is good description in the Naming series form and how to test the series.

I haven’t actually implemented but pretty confident that this will give you the desired result. Reach out if you hit a roadblock.

1 Like