Workflow state change does not trigger on_update / validate in custom DocType

Hello

I’m facing an issue with workflow state changes in Frappe.

When I apply a workflow on a custom DocType, the workflow_state field changes properly when I approve/reject using workflow actions. However, I noticed that my validate and on_update methods are not getting triggered when the state changes only via workflow.

For example, in my DocType’s Python class:

class CustomDoc(Document):
    def validate(self):
        frappe.msgprint("Validate called")

    def on_update(self):
        frappe.msgprint("On Update called")

When I change normal fields and save → these methods run fine.
But when I change the state using a workflow action (e.g. Approve/Reject) → these methods do not always run.

Validate works on apply workflow. Can you please explain your use case?

1 Like

hello @DaizyModi

When the user updates the workflow status from an action, I had already set a condition in the on_update and validate functions to trigger the validation logic. However, it did not trigger as expected. According to your response, the validate function should work, so I will test it again.

@DaizyModi Thank you for your reply. I checked again, and it works properly this time. It might have been a cache issue or something similar.

1 Like