Hello, I need to reject the document if any quantity is entered in “Rejected Qty” in purchase invoice. I wrote below client script but not working.
frappe.ui.form.on("Purchase Invoice Item","before_save", function(frm) {
if ( frm.doc.rejected_qty > 0) {
msgprint('check rejected quantity');
validated = false;
}
}
);
Feel like the event should be applied on the parent doctype as the purchase items are stored in a child table. Try the code below, or take a look at child table events. Form Scripts
frappe.ui.form.on("Purchase Invoice", {
before_save(frm) {
for(var i=0; i<frm.doc.items.length; i++){
if(frm.doc.items[i].rejected_qty>0){
//your code here
}
}
}
});
2 Likes
I’m not much of a coder. This worked!
Thanks a lot brother!