I need to fetch the expiry date from the “Batch” doctype to the delivery note item. When the batch is selected the expiry date should automatically be fetched upon saving the document. I tried below but it does not work!
frappe.ui.form.on("Delivery Note Item", {
before_save(frm) {
for(var i=0; i<frm.doc.items.length; i++){
cur_frm.add_fetch("batch_no","expiry_date","expiry_date");
}
}
}
});
NCP
April 7, 2022, 3:52pm
2
Hi @thelahera ,
In child-level script does not work for before_save.
When you select batch no then will automatically fetch the value from Batch.
So you can apply it.
frappe.ui.form.on("Delivery Note Item", "batch_no", function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.db.get_value("Batch", {"name": d.batch_no}, "expiry_date", function(value) {
d.expiry_date = value.expiry_date;
});
});
Thank You!
1 Like
Unfortunately, this does not work. I tried many times to correct it without bothering you but it did not work. Thank you so much for your effort.
NCP
April 15, 2022, 8:09am
4