I need to make validation like validation on the course schedule creating tool but on event document, I have a custom field called instructor and I need avoid overlapping for a set instructor for multiple events in the same date, and I think of adding def in event.py check if the instructor has an event in the same date when saving the event doc by checking this in the database
any idea for that
Try setting the Unique
flag.
thanks for your reply
this feature only for one filed value but what i need to compare it with date if it’s set to him in another doc int the same date
That’s what the unique flag does.
Dear @tmatteson
thanks for your response
i’m already made instructor field unique but nothing happen the system able to save an event document while the instructor has other event in the same date
Because there’s a date range (missed that) you need a server side method that does exactly what you describe. The unique flag is not what you want, sorry about that.
To understand the next step for you I think I need more context about your project. Would this be a contribution? How far have you gotten with code for this?
Thanks @tmatteson
I’m trying this code but I got a syntax error
validate: function(frm) {
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Event",
fieldname: "client",
filters: {
"customer": frm.doc.client,
"date": frm.doc.starts_on
}
},
callback: function(r, rt) {
if (r.message.client) {
frappe.throw(__(“Event {0} is already exists.”, [r.message.client]))
}
}
});
}
Do you have any suggesti