I have a doc “Purchase Order” - parent
“Purchase Order Items” - child table with fieldname as “items”
In child table “items” - 2 filelds “item_code” and “custom_mpn” where custom_mpn is a select field
I want to dynamically add options to “custom_mpn” based on the “item_code”
I tried with code in client script when
frappe.ui.form.on(“Purchase Order Item”,{item_code:function(frm,cdt,cdn) {
var row = locals[cdt][cdn];
if(row[“item_code”] == “a”)
{
frappe.utils.filter_dict(cur_frm.fields_dict[“items”].grid.docfields,
{“fieldname”: “custom_mpn”})[0].options = [" “,“a”,“b”]
cur_frm.refresh_field(“custom_mpn”);
}
else
{
frappe.utils.filter_dict(cur_frm.fields_dict[“items”].grid.docfields,
{“fieldname”: “custom_mpn”})[0].options = [” ",“c”,“d”]
cur_frm.refresh_field(“custom_mpn”);
}
}
});
It is not adding any options to the field