Workflow - How to undo last transition?

Is it possible to undo last transition that was performed, and come back to the previous state ?

Add an action to the final state which turns the document back to the previous state

What if both StateA and StateB can bring to StateC.
While in StateC, I want to undo previous transition and go back to previous state (could be A or B but not both).

Then create a new hidden field “last_state” to store the last state, and update your workflow accordingly (Update Field)
Using a client script, add an Undo button to your actions menu.

Something like this, not tested.

frappe.ui.form.on('DocType', {
    refresh: function(frm) {'Undo', function() {
            frm.set_value('workflow_state', last_state);
1 Like