Generate Item Code Based On Custom Logic
Add this Custom Script in the script of Item, so that the new Item Code is generated just before the Item gets saved.
cur_frm.cscript.customvalidate = function (doc) {
// clear itemcode (name is from itemcode)
doc.itemcode = "";
// first 2 characters based on itemgroup
switch (doc.itemgroup) {
case "Test A":
doc.itemcode = "TA";
break;
case "Test B":
doc.itemcode = "TB";
break;
default:
doc.itemcode = "XX";
}
// add next 2 characters based on brand
switch (doc.brand) {
case "Brand A":
doc.itemcode += "BA";
break;
case "Brand B":
doc.itemcode += "BB";
break;
default:
doc.itemcode += "BX";
}
};
Adapted for EnigmaERP from the ERPNext documentation,
© Frappe Technologies Pvt. Ltd. Content licensed under
CC-BY-SA 3.0.
EnigmaERP is a product of Enigma and is not
affiliated with or endorsed by Frappe Technologies Pvt. Ltd.