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”:
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;
});
})