Try ERPNext Buy Support Partners Foundation

Hooks to capture workflow transition

Hi

My use case is to capture the transition of workflow on doctype when it moves from state A to state B. I am using workflow_state_var as the default status parameter and I tried to capture the change and perform some actions (call whitelisted server functions) but unable to do so. Here’s the relevant part of code snippet:

frappe.ui.form.on('Lead Fetch', {
    workflow_state_var: function(frm, doc) {
        console.log("Test function")
    },

So, basically I need to call a function when the doctype workflow state moves from A to B. aka when workflow_state_var's value is changed

Check following thread,

Thanks for the response. No that doesn’t solve my purpose. I don’t want to hardcode the workflow states in my code.

Simply a trigger on when a workflow state is changed is enough for me. Is there no way to do this?

Okay, then you can simply do it on validate. Workflow state gets changed on save.
write your code on validate.