can anyone demo how we can write simple schedular events in ERPNext Cloud Hosted in server Script.
thanks in advance.
can anyone demo how we can write simple schedular events in ERPNext Cloud Hosted in server Script.
thanks in advance.
are you talking about crons ? a code that runs in a specific datetime ?
yes based on time.
open your custom app ( or open frappe if you donât have a custom app).
the same folder where the file hooks.py is . create a python file , with any function you want .
next, open hooks.p . find a dict name âscheduler_eventsâ . and add the path of your function to any of the events you want (all,hourly,weeklyâŚ) or create a cron event (if you dont already have it) . this way :
scheduler_events = {
"cron": {
"0 0 * * *": [
"frappe.file_name.function_name",
]
},
"all": [ ...
The above function will be triggered every 00:00 (midnight) . (check the website âcrontab guriâ to learn how to write crons )
thatâs it
i think we cannot write hooks.py on cloud hosted erpnext.i am using cloud hosted erpnext. i want to run scheduler events on cloud hosted erpnext
canât you just open the server and write codes in the server side ?
no in cloud hosted erpnext we cannot on developer mode.
just chose the frequency and write your script there
can your share one simple example.
i want to trigger it at 6 PM every evening everyday.
can we do that??
you can make it hourly , and check the time if itâs 6 run the code .
however the server script has very limited resources . you canât write much code here .
try to open the server and write it in the hooks.py
if you had done this type of code can you share?
Iâve done many . I just told you how to write it . just open the server . there is no way you installed erpnext without access to the back server . how can you upgrade ? switch branches if you donât have access ?
okay will do
i run the schedular event but after execute it is complete but mail not send. and it is not in Email Queue also.
what is the issue?
indent preformatted text by 4 spaces
def send_mail_custom(recipient,content):
frappe.sendmail(recipients=[ârehan@test.comâ],
sender="notifications@test.com",
subject=âPurchase Order Alertâ, content=content)
this is the code.