hello everyone don’t if this the right place to ask frappe related queries ?
but if yes the i am facing some confusions
like i have create the schduler event like this. What’s happening is that when I call it from the scheduler, it doesn’t store any data in the database. However, when I test it as an API using @frappe.whitelist(allow_guest=True), it works fine. What could be the issue?
“0 * * * *”: [
“pharm_ehr_tenant.integrations.srs.store_srs_response”
],
i ask to claude AI and it gives me some solutions
here is what AI gives
Scheduler Has No frappe.set_user() — Permission Silently Blocks Inserts
When running via scheduler, the user context may be Guest or empty, causing ignore_permissions=True to be needed everywhere — but frappe.get_value() and frappe.get_all() do not have ignore_permissions in your code. They might return None/empty silently.
frappe.db.commit() Inside Loop — But Scheduler May Be Rolling Back
In the scheduler context, if any unhandled exception occurs after your loop but before the job finishes, Frappe’s job runner can issue a rollback on the whole transaction. Your frappe.db.commit() is inside the for row loop but outside the company try/except, meaning a company-level exception after rows are processed could wipe inserts.
Fix: Move frappe.db.commit() to also appear at the end of each company block
helpe if i have missed anythings