Auto populating vales in child table with values in the parent form

Can someone kindly help me with the following.

I created a custom DocType called Supervior Details. In this DocType, i have several fields of which two are called supervisor_name and supervisor_code. This custom DocType (Supervisor Details) was added to the Delivery Note form as a table. In the Delivery Note form, i have two custom fields called supervisor_name and supervisor_code.

I would like to have a script that will populate supervisor_name and supervisor_code in Supervisor Details with the values entered in supervisor_name and supervisor_code in the delivery note.

So when creating a new delivery note, the user enters supervisor_name and supervisor_code. Then move further to Supervisor Details and click on add row. The two fields supervisor_name and supervisor_code in this table should automatically be populated with the values entered in the fields in the delivery note.

Looking forward to any assistance. Thank you.

you can accomplish this by creating a custom script for Delivery Note doctype that has this code:

frappe.ui.form.on('Supervisor Details', {
yourChildTableFieldName_add: function(frm, cdt, cdn){
	var d = locals[cdt][cdn];
	frappe.model.set_value(cdt, cdn, "supervisor_name", frm.doc.supervisor_name);
        frappe.model.set_value(cdt, cdn, "supervisor_code", frm.doc.supervisor_code);



Thank you! This works perfectly!!