Achieved by using this script.
But when i create form and after saving it i edit the form its validate me to edit anything because the record already exist with the same employee and same date.
seems like trigger issue, i just want this function to run while creating form.
can anyone point out that where am i wrong?
frappe.ui.form.on("Time Tracking", "validate", function(frm) {
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Time Tracking",
fieldname: "name",
filters: {
employee: frm.doc.employee,
period_start_date: frm.doc.period_start_date,
period_end_date: frm.doc.period_end_date
}
},
callback: function(response) {
var employee = response.message;
if (employee) {
frappe.msgprint("Same Employee with the Same Time Period is Already Exist in Record.");
validated=false;
return false;
}
}
});
});