How to invoke Workflow action through js?

I’m trying to invoke the worflow action through js. I dont know howto get hold of the action buttons. Any ideas?
I need something like or


@kirthi, the unique thing that the click do is update the workflow_state field, and invoque the frm.save_or_update function!


Thanks @max_morais_dmm Will try.

Great!!! it worked @max_morais_dmm

My code - just in case anyone is looking for a reference -

frappe.ui.form.on(“Purchase Order”, “validate”, function(frm) {
if (frm.doc.approval_state == ‘Pending Approval’ && frm.doc.authorized_tmp != ‘Yes’) {
validated = false;
//do your stuff
else if (frm.doc.approval_state == ‘Approved’ && frm.doc.authorized_tmp != ‘Yes’) {
validated = false;
//do your stuff
else { frm.doc.authorized_tmp = ‘No’;}

I needed to add a tmp variable to prevent cyclic loop of saving/submission.

1 Like

Hello @max_morais_dmm ,

May I request for your advice!

In JS, I want to catch the workflow action, validate some field value, (if not validated ) set focus to the said field and stop workflow action (i.e. stop the change of workflow_state). Please guide me.