Hi everyone,
I’m working on a Frappe app where I need to have finer control over the workflow and approval process. Specifically, I want to:
-
Access the
docstatusof a document (0 = Draft, 1 = Submitted, 2 = Cancelled) programmatically. -
Change the
docstatusunder certain conditions (e.g., auto-submit or cancel after certain validations). -
Possibly trigger additional server-side logic whenever
docstatuschanges (like updating other fields, sending notifications, or logging).
My current challenges:
-
Frappe prevents direct updates to
docstatusbecause submitted documents (docstatus=1) cannot be modified without unsubmission. -
I’m trying to automate certain workflow steps without manually clicking buttons, while ensuring data integrity.
-
I’d like to know the best practices for safely updating
docstatusand related fields, ideally using server scripts or hooks.
Some specific questions:
-
Can we safely submit/unsubmit a document programmatically in server scripts?
-
How can I update fields or trigger actions after a workflow changes
docstatus?
I’d appreciate any guidance, sample patterns, or references for handling docstatus programmatically while keeping workflow integrity intact.
Thanks in advance!