Remove duplicate data from child table and how to load the child table details from Another doctype

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® {

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

You can use frm.clear_table("risk_profile_details"); to clear the table before appending the data.

@nabinhait, it’s working Thanks. But we are facing problem Duplicate Risk Name whenever we save the page. It is already in the risk_profile_details object.

hello sir
Is this problem resolve?
If this resolve , then can you please share how … I also facing same problem.
thank you
regards sakshi