check duplicate record base on first_name middle_name last_name extension name birthday and barangay
That for, you can use the client script.
Sample syntax.
frappe.ui.form.on('Your DocType', {
validate: function (frm) {
frappe.call({
method: "frappe.client.get_list",
args: {
doctype: "Your DocType",
filters: {
first_name: frm.doc.first_name,
middle_name: frm.doc.middle_name,
last_name: frm.doc.last_name,
extension_name: frm.doc.extension_name || "",
birthday: frm.doc.birthday,
barangay: frm.doc.barangay
},
fields: ["name"]
},
callback: function (response) {
if (response.message && response.message.length > 0) {
frappe.throw(__('Duplicate record found. Similar record exists with name: {0}', [response.message[0].name]));
}
}
});
}
});
You have to set the doctype name and field name in the script.
Otherwise, you can also use the server script.
duplicate = frappe.db.exists(
"Your DocType",
{
"first_name": doc.first_name,
"middle_name": doc.middle_name,
"last_name": doc.last_name,
"extension_name": doc.extension_name or "",
"birthday": doc.birthday,
"barangay": doc.barangay
}
)
if duplicate and duplicate != doc.name: # Ensure it's not the same record
frappe.throw(f"Duplicate record found with the same details. Record ID: {duplicate}")
1 Like
Also sir how can i import bulk image base on id_no? thank you