ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Autofill custom field in item from master

I have added new custom field to Purchase order and Purchase order item. Custom field name is exp_date in both.

Now when user selects the exp_date in the Purchase order I want to autofill all items exp_date as same value. How we can achieve this?

I am using below code to achieve same but not working:
frappe.ui.form.on(“Purchase Order Item”, “exp_date”, function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.db.get_value(“Purchase Order”, {“name”: d.exp_date}, “exp_date”, function(value) {
d.exp_date = value.exp_date;
});
});

Here value remains undefined.

Frm.doc.exp-date has data. simply use
d.doc_exp= frm doc exp_date

And instead of exp_date_add event use item-add event