i’m using below code for avoiding overlapping for a custom field called facilitator in Event document so I need to check facilitator name against date so if he has another document saved in the same event start and end time not able to save the document but the code not working properly
frappe.ui.form.on("Event", "validate", function(frm) {
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Event",
fieldname: "facilitator",
filters: {
client: frm.doc.facilitator,
starts_on: frm.doc.starts_on,
ends_on: frm.doc.ends_on
}
},
callback: function(response) {
var facilitator = response.message;
if (facilitator) {
frappe.msgprint("Same facilitator with the Same Time Period is Already Exist in Record.");
validated=false;
return false;
}
}
});
});
You need to write a python function for this or handle it in the custom script. I understand what you’re trying to do but this code doesn’t make much sense.
Thanks for your response, unfortunately, the code is not working it only checks the validation in the first time and then change the date to be in the same period it’s not validated for example if I have event from 11 July to 13 July and I make new event from 12 to 13 its save normally and didn’t make any validation
Dear @Mukesh_Variyani
thanks for your response but there is a syntex error
SyntaxError: Unexpected token ,
at Class.setup (http://erp.shiftits.com:81/assets/js/form.min.js?ver=1532943067.0:2691:18)
at _f.Frm.setup (http://erp.shiftits.com:81/assets/js/form.min.js?ver=1532943067.0:172:22)
at _f.Frm.refresh (http://erp.shiftits.com:81/assets/js/form.min.js?ver=1532943067.0:446:9)
at Class.load (http://erp.shiftits.com:81/assets/js/form.min.js?ver=1532943067.0:87:33)
at http://erp.shiftits.com:81/assets/js/form.min.js?ver=1532943067.0:82:7
at Object.callback (http://erp.shiftits.com:81/assets/js/desk.min.js?ver=1532943067.0:5516:6)
at Object.callback [as success_callback] (http://erp.shiftits.com:81/assets/js/desk.min.js?ver=1532943067.0:1437:16)
at _ (http://erp.shiftits.com:81/assets/js/desk.min.js?ver=1532943067.0:1461:34)
at Object. (http://erp.shiftits.com:81/assets/js/desk.min.js?ver=1532943067.0:1562:5)
at i (http://erp.shiftits.com:81/assets/frappe/js/lib/jquery/jquery.min.js:2:27151)