Restriction on Multiple Scheduling

Hello Guys,

I would like to create restriction on Scheduling “Meeting Module” for Duplication.

for example:

if end user Schedule on January 04, 2018 at 4pm
if system detect Same Scheduled
frappe.msgprint(“Sorry! please try again”);
else
end user Schedule on January 04, 2018 at 5pm
if system didn’t detect Same Scheduled
frappe.msgprint(“Congratulations! Scheduled Success!”);

Sorry guys,

I’m a new on ERPNext.

My question is, how can I create this using custom script on ERPNext

Regards,
@Foxdemon96

you have to write simple python script for that
and into hooks.py include your python method path for meeting schedule doctype

def validate(doc,method):
existing_records=frappe.db.sql(“”" select name from tabMeeting Schedule where start_date>=‘{0}’ “”".format(doc.start_date),as_list=True)
if existing_records:
frappe.msgprint(“Sorry! please try again”);
else:
frappe.msgprint(“Congratulations! Scheduled Success!”);

:slight_smile:

Hello @AkshayJadhao

Sorry for my question, but is there any way I can input this on custom script.

I try this, but I’ve got Unexpected identifier error.

regards,
@Foxdemon96

i am not getting what you want to say please elaborate with small example
:slight_smile:

Hello @AkshayJadhao,

Sorry about that.

I try this script lately.

frappe.ui.form.on(“Meeting”, “before_save”, function(frm) {
if(frm.doc.start = frappe.datetime.nowdate()){
frappe.msgprint(“Please select other Schedule”);
validated = false;
}
}
);

I able to restrict, but the problem is that I can’t create schedule on this.

Regards,
@Foxdemon96

in this script you are trying to restrict the document from save if entered start date and today’s date is same

so now what you want ??

as per your initial problem you said you want to show msg if meeting schedule is override

in hooks.py incude this

doc_events = {
“Meeting Schedule”: {
“validate”: [“path.to.custom.method.validate”]
},
}

and write your custom .py method like this

def validate(doc,method):
existing_records=frappe.db.sql(“”" select name from tabMeeting Schedule where start_date>=’{0}’ “”".format(doc.start_date),as_list=True)
if existing_records:
frappe.msgprint(“Sorry! please try again”);
else:
frappe.msgprint(“Congratulations! Scheduled Success!”);

kindly check proper indentations and path to your custom method or any syntactical errors

:slight_smile:

Hello @AkshayJadhao,

I create that script, I thought I able to restrict multiple scheduling on meeting module
but I fail,

I’m new with the ERPNext.

So, I able to share with you my script if I’m correct based on my understanding about little knowledge about using custom script on ERPNext but I don’t get it totally.

I hope you can help me on this matter.

regards,
@Foxdemon96

in hooks.py incude this

doc_events = {
“Meeting Schedule”: {
“validate”: [“path.to.custom.method.validate”]
},
}

and write your custom .py method like this

def validate(doc,method):
existing_records=frappe.db.sql(“”" select name from tabMeeting Schedule where start_date>=’{0}’ “”".format(doc.start_date),as_list=True)
if existing_records:
frappe.msgprint(“Sorry! please try again”);
else:
frappe.msgprint(“Congratulations! Scheduled Success!”);

kindly check proper indentations and path to your custom method or any syntactical errors

can you try this solution this is super easy
:slight_smile:

Hello @AkshayJadhao,

Thank you so much for your help.

I will try this.

regards,
@Foxdemon96

Hello @AkshayJadhao,

I received custom script error.

regards,
@Foxdemon96

Hello @AkshayJadhao

Sorry about yesterday.

I forgot to mention,

if you don’t mind

How I can access hooky.py

I’m using putty

thanks in advance.

regards,
@Foxdemon96

this will help you now

you have to make changes in ’ meeting_schedule.py ’

def validate(self):
if self.start_date > self.end_date:
frappe.throw(_(“Start Date cannot be after End Date”))
existing_records=frappe.db.sql(“”" select name from tabMeeting Schedule
where start_date>=‘{0}’ and end_date<=‘{1}’ “”".format(self.start_date,self.start_date),as_list=True)
if existing_records:
frappe.msgprint("Sorry! please try again meeting exist already on this date ");
else:
frappe.msgprint(“Congratulations! Scheduled Success!”);

please check proper indentation s and comas [ , ’ , " ] because if you are directly copy and paste code it dose not go as i have written here better way is to use editor

i have tested this on my system and it is working fine if you get any error then probably it will any minor syntactical error

:slight_smile:

Hello @AkshayJadhao

Thank you so much for your time.

Regards,
@Foxdemon96

have you solved ?

Hello @AkshayJadhao

not yet, I’m still trying to do it now.

I hope, I can make it.

Thanks for your help, I really appreciate.

Regards,
@Foxdemon96

Hello @AkshayJadhao

I have one question.

Is it Okay if I’m going to input this
on custom script?

Regards,
@Foxdemon96

yes you can write custom script for it

1 Like

Hello @AkshayJadhao

but I received

image

Sorry If I don’t get it.

Regards,
@Foxdemon96

oh sorry i thought you are modifying python file

this way i think is little bit difficult to manage such condition

cant you just change your python code ?

Hello @AkshayJadhao

Sorry about that.

I think I’m not sure if I able to change it
Since I’m new with the ERP.

Thank you for your help on this.

Regards,
@Foxdemon96