We have one doctype where we save our Risk Profile Details.
We have another doctype name as Lead.
Now what we want to do is load Risk Profile Details of particular lead in child table name as ‘Lead Risk Socket’ in Lead Doctype
frappe.ui.form.on(‘Lead’, {
refresh: function(frm) {
dashboard_link_doctype(frm, “Risk Profile”);
console.log(frm.doc.risk_profile_details)
frappe.call({
method:“frappe.client.get_list”,
args: {
doctype:“Risk Profile”,
fields:[ ‘risk_appetite’,‘name’,‘reason’,‘creation’,‘investmentamount’],
filters: {
lead: frm.doc.name
},
order_by:‘idx’
},
async:false,
callback: function(r) {
console.log(frm.doc.risk_profile_details)
$.each(r.message, function(i, d) {
var row = frappe.model.add_child(frm.doc, "Lead Risk Socket", "risk_profile_details");
console.log(row)
row.risk_name= d.name;
row.risk_appetite= d.risk_appetite;
row.reason= d.reason;
row.creation= d.creation;
row.investment_amount=d.investmentamount;
refresh_field(“risk_profile_details”);
});
}
});
}
});
Now through above code what is happening whenever we refresh the page the data get appended in the risk_profile_details(Child Table) table.
Below is the screenshot