Hi,
Can someone help me… I have to automatically populate list of child companies in a child table row by row when a parent company is selected in the same child table. I have done halfway but the all the company is getting selected in the same row itself. I want it row after row
Below is my script
frappe.ui.form.on("Item Default","company",function(frm,cdt,cdn){
var d=locals[cdt][cdn];
var c=[];
if(d.company=="Company-01"){ //Check if it is the parent company
console.log(d.company);
var comp=frappe.db.get_list('Company',{
fields:['company_name'],
filters:{
parent_company:'Company-01' // Get all the child company
}
}).then(records=>{
console.log(records);
var d=records.length>0?records:[]
for(var i=0;i<d.length;i++){
var ff=d[i].company_name;
c.push(ff)
}
frappe.model.set_value(cdt,cdn,"company",c)
})
}
});
Thanks…In advance