Insert unique record each row in child table. but below code it just duplicating all the values whenever the Insert button is clicked

var current_user = frappe.session.user;
frappe.ui.form.on(“Milk Entry”,{
verify: function(frm) {{
method: “frappe.client.get”,
args: {
doctype: “User”,
filters: {“email”:current_user} //user is current user here
callback: function(r) {
frappe.model.add_child(cur_frm.doc,“Milk Entry List”,“milk_list”);
$.each(frm.doc.milk_list || [], function(i, v) {
frappe.model.set_value(v.doctype,, “code”,cur_frm.doc.member)
frappe.model.set_value(v.doctype,, “milk_type”,cur_frm.doc.milk_type)
frappe.model.set_value(v.doctype,, “volume”,cur_frm.doc.volume)



any solution?

Well the problem is you’re not checking what is in the child table before appending something. First check if the milk list already has what you’re about to set it to. In the callback function.

Or use the form events that triggers when the child table changes to check for duplicates documentation