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.custom\_validate = function(doc) {
// clear item\_code (name is from item\_code)
doc.item\_code = "";
// first 2 characters based on item\_group
switch(doc.item\_group) {
case "Test A":
doc.item\_code = "TA";
break;
case "Test B":
doc.item\_code = "TB";
break;
default:
doc.item\_code = "XX";
}
// add next 2 characters based on brand
switch(doc.brand) {
case "Brand A":
doc.item\_code += "BA";
break;
case "Brand B":
doc.item\_code += "BB";
break;
default:
doc.item\_code += "BX";
}
}
Last updated 1 month ago
Was this helpful?