Data communication between parent table and child table

I customized Delivery Note and Delivery Note Item by inserting in both of them the same new field: Delivery Date (delivery_date).

Since they both have the same name (delivery_date), shouldn’t it automatically fetch the date in Delivery Note Item once I insert the date in the Delivery Note?

When I insert the date in the Delivery Note, it does not automatically appear also in the Delivery Note Item.

For example, I inserted the Delivery Date in box within the Delivery Note. Then, I inserted the item code and quantity; but when I open the triangle on the right side the Delivery Date does not appear automatically in the Delivery Note Item.

Why? How can I fetch them automatically?
I want the delivery date in the second box to appear automatically once I insert it in the first box.

@wami_erp

You can do this by editing the delivery_note.js file. Please find the code below!

frappe.ui.form.on("Delivery Note", {
	delivery_date: function (frm) {
		for(var i=0; i<cur_frm.doc.items.length;i++){
			cur_frm.doc.items[i].delivery_date=cur_frm.doc.delivery_date
		}
		cur_frm.refresh_fields("items")
	},
	onload: function (frm) {
		for(var i=0; i<cur_frm.doc.items.length;i++){
			cur_frm.doc.items[i].delivery_date=cur_frm.doc.delivery_date;
		}
		cur_frm.refresh_fields("items")
	}
});

frappe.ui.form.on("Delivery Note Item", {
	items_add: function(frm,dt,dn){
		for(var i=0; i<cur_frm.doc.items.length;i++){
			cur_frm.doc.items[i].delivery_date=cur_frm.doc.delivery_date;
		}
		cur_frm.refresh_fields("items")
	}
});

Hope this helps!

1 Like

Dear @Shah_Kalpit it works great!
thanks a lot for the help! :smiley:

Have a good day

1 Like