[v12] Client side events not working while performing workflow actions

I created a workflow on Work Order doctype. It is working fine. But when I checked the JS triggers I found that on performing workflow action nothing gets triggered in a custom script.

My custom script work_order.js

frappe.ui.form.on('Work Order', {
refresh: function(frm){
	console.log("refresh...")
},

validate: function(frm) {
	console.log("validate...")
},

on_submit: function(frm){
	console.log("submitting...")
},});

Trigger validate working normally while saving the document.
But when changing workflow state this is not working. Similar things observed on the on_submit trigger.

If I disabled the workflow then everything is work properly.

My workflow doc.

1 Like

Hi @abhijit_kumbhar

Encountering same issue here. Did you find a solution pls?

Kind regards,

workflow action doesn’t trigger form event in JS. It trigger on_update event in python.

1 Like

Hi @ashish-greycube

Thanks for the feedback. So how do you use this as a trigger in a custom script (client side)? An example would help make things clearer

Thanks

Anyone has any suggestions please?

Kind regards,

hooks.py

doc_events = {
	"Issue": {
		"on_update": "custom_app.api.update_issue_on_go_back_action",
		"on_update_after_submit": "custom_app.api.update_issue_on_go_back_action",}}

api.py

def update_issue_on_go_back_action(self,method):
   	workflow_action=frappe.db.get_list('Workflow Action',
    filters={
        'reference_name': self.name,
		'reference_doctype':'Issue'
    },
    fields=['status', 'user','workflow_state'],
    as_list=True
)
if (len(workflow_action)==1):
		workflow_action_status=workflow_action[0][0]
		workflow_action_workflow_state=workflow_action[0][2]
# you have now all the required field value..based on that take your action
	if (self.workflow_state=='Open' and self.status=='Closed' and self.docstatus==0 and self.issue_type==None and workflow_action_status=='Open' and workflow_action_workflow_state=='Open' ):
			self.db_set('status', workflow_action_status, update_modified = True)

I am facing same problem. @ashish-greycube i want custom script js solution.Is there any solution available for client side.??