Create custom events based on workflow states

I want to create events when there’s a transition of states using a custom workflow? How can I do it?

Is this right?

suppose the workflow transition from unapproved to approved reflected on the doc’s workflow_status field as wait_approve and approved.

you can use the standard on_update or on_change event as below

doc_before_save = doc.get_doc_before_save()
if doc_before_save.workflow_status == 'wait_approve' and doc.workflow_status =='approved':
    blabla

Is doc.doc.get_doc_before_save() a legit code in frappe?

Thanks! I’ll try this.

please kindly confirm whether your issue has been resolved.

thanks.