Value into child table, or value out of child table

Hey all. I’m trying to find a way to put data into a field in a child table, or pull a value out of a field into a parent form.

I’ve looked around the forum at many examples of
calculations and some conditional programming or filtering done with tables, but can’t get the simple data pulling figured out.

Bad example:

Doctype: Sales invoice,
Parent field: Customer
Child table: Sales invoice item
Child table field: item_customer

These aren’t the actual fields I’ll be using, but I’m trying to figure out what code to use to pull from item_customer to customer based on any item field change.

Also, secondary to that, wondering what would be used to insert Customer value into item_customer when customer is selected.

Any tips or help would be greatly appreciated.

Try something like this to update value in parent table:

frappe.ui.form.on("Sales invoice Item", "item_customer", function(frm,cdt,cdn) {
	d = locals[cdt][cdn]
        frm.doc.customer = d.item_customer
});
2 Likes

I can’t believe how many hours I spent trying to figure that out. Worked perfectly! Thank you!