I have a Child Table is Parent Information Details in Leads Doctype.
In child Table form, i have province_id and district_id are link field to Province and District Doctype.
I want to query district has province_id was choose in province_id field.
this is my code:
frappe.ui.form.on(“Parent Information Details”, “provinceid”, async function (frm, cdt, cdn) {
let row = locals[cdt][cdn];
let province = row.provinceid;
/*
//This is the code i can get district by province but i dont know how to set it to districtid in child table
const districtList = await frappe.db.get_list(‘District’, { filters: { ‘province_id’: province }, fields: [‘*’] });
console.log(districtList);
frappe.db.set_value(cdt, cdn, 'districtid', districtOptions); */
//This code is not working
frm.set_query('districtid', 'parent_information_details', function () {
return {
filters: {
province_id: province
},
fields: ['*']
};
});
});