Child Table Custom Script

Hello ERPNext Community,

I have made a Parent “DocTypeA”.
Inside that I have added a child table “DocTypeB” with 4 fields. The first field is a link to “Employee” doctype. The other fileds are ‘Salutation’, ‘employment type’ and ‘date of joining’. Now I want that the values of the three fields in the table row be fetched automatically when I select The Employee from the link that is the first field of the table. It seems very easy and I added this code in custom script of child table “DocTypeB”:

cur_frm.add_fetch(“employee”,“salutation”,“salutation”);
cur_frm.add_fetch(“employee”,“employment_type”,“employment_type”);
cur_frm.add_fetch(“employee”,“date_of_joining”,“date_of_joining”);

But I came to know that custom script does not work for child table. So how can I write the same script from the parent “DocTypeA” custom script??

Someone, please help me if they know how to do this…
Thanks

frappe.ui.form.on("Sales Order Item", "item_code", function (frm, cdt, cdn) {
    //Fetch reservation_option from item on item code change on Sales Order Item
    var d = locals[cdt][cdn];
    frappe.db.get_value("Item", { "name": d.item_code }, "reservation_option", function (value) {
        d.reservation_option = value.reservation_option;
    });
})

This did not work for me…
Here is a my script for “Fetch test” Doctype… It contains a “Fetch test table” doctype in which employee linked field is there.

frappe.ui.form.on("Fetch test table", "employee", function (frm, cdt, cdn) {
    //Fetch reservation_option from item on item code change on Sales Order Item
    var d = locals[cdt][cdn];
    frappe.db.get_value("Employee", { "name": d.employee }, "first_name", function (value) {
        d.employee_name = value.first_name;
    });
})

I think I need to update the table field after this??

https://docs.erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts

Check out No. 12

Thanks for the help!! It worked after I added cur_frm.refresh_field(“fieldname”)