Hi,
I would like to validate that there is no duplication in Item Price. The parameters are Item Code, Price List and Batch No so I tried the following script but it seems doesn’t work as I am getting a false error that there is a duplication.
frappe.ui.form.on("Item Price", "validate", function(frm) {
if(frm.doc.__islocal)
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Item Price",
fieldname: "name",
filters: {
item_code: frm.doc.item_code,
price_list: frm.doc.price_list,
batch_no: frm.doc.batch_no
}
},
callback: function(response) {
var item_code = response.message;
if (item_code) {
frappe.msgprint("The same item with the same price list & same batch no already exists");
validated=false;
return false;
}
}
});
});
I followed the same example in this topic Validate Duplication on two fields - #4 by shahid
Can someone advise how to solve?
Regards,
Ahmed Sharaf