Hi,
I need to get parent docname in child table field.
for example,
I am creating a Sales Order and it has a naming series , i need the same name in child table when its saved.
I tried the below custom script but not working, kindly help
frappe.ui.form.on(‘Sales Order’, {
refresh: (frm) => {
cur_frm.fields_dict.items.grid.get_field(‘naming_series’).get_query = function (doc, cdt, cdn) {
return {
filters: {
‘naming_series’: parent.doc.name
}
};
};
}
});
After trying the below code, its getting copied but the name is different
frappe.ui.form.on(‘Sales Order’, {
on_submit: function(frm) {
var last_id = frm.doc.sales_order_item.length - 1;
frappe.model.set_value(frm.doc.sales_order_item[last_id].doctype, frm.doc.sales_order_item[last_id].name, “name”, frm.doc.name);
}
});
please find the attached screenshot, the ID field is getting this type of series
You can change the naming series from child table doctype, each row in the child table here has a unique name.
You cant set the same name as the parent for all rows of the child table.
If that what you mean!
Thanks for the info, actually i am trying to set or copy the same naming series or name of parent to the child table name field. Is this possible by anyways?
Parent table is Sales Order and child table is Sales Order item