I have child table in purchase receipt named “purchase receipt item”, it has expiry date on the child table. I need that data to auto fill in Batch - expiry_date field. is anyone can help me with this? Thankyou so much
i want to fetch from child table to master, does this script are same?
It’s retrieving the expiry_date value from the batch doctype for the sales invoice item.
Thank You!
i was really clueless, can u tell me more?
i need the expiry_date data from purchase receipt item to batch doctype
expiry_date is available on the batch doctype, not a purchase invoice item doctype.
Provided script, if you want to batch expiry_date date set into the purchase invoice item then you have to add the custom field like expiry_date.
use it and check it.
Thank You!
But I have child table named purchase receipt item and i adding expiry date field on it. I want to set the expiry date on doctype batch. that was the condition. can you help me with that?
Please apply the client script.
frappe.ui.form.on("Purchase Receipt Item", "expiry_date", function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
var batch_no = d.batch_no;
if (batch_no) {
frappe.db.set_value("Batch", batch_no, "expiry_date", d.expiry_date, function(response) {
if (!response.exc) {
frappe.msgprint("Expiry date updated in Batch: " + batch_no);
} else {
frappe.msgprint("Failed to update expiry date in Batch: " + batch_no);
}
});
}
});
When you select the expiry_date for a purchase receipt item, the expiry_date will be updated on the batch doctype.
Make sure to set the field name in the script correctly and double-check it for accuracy based on the scenario.
Thank You!
Do i also need to code something on the server script? thankyou so much !
No, it’s a client script, you can put the script on the client script doctype.
what if i want to fetch expiry_date data from child table in purchase receipt to doctype batch? is it work the same?
You have to learn yourself and try it.
Reference:
Thank You!