Before_workflow_action wait for user action

Hello,
I have this simple client script:

frappe.ui.form.on('Task', {
    before_workflow_action: (frm) => {
        if ((frm.selected_workflow_action === 'Reopen'))
        {
          frappe.confirm('Are you sure you want to proceed?',
            () => {   
         }, () => {
                     frappe.throw("stop");
            })
        }
        
    },
});

But the workflow action does not wait for user action and the workflow state changes to new state immediately.
How can I do that, please?

Hi @Jiri_Sir you can use Promise function on the client script:

	before_save: function(frm){
		return new Promise(function (resolve, reject) {
			// This will cancel save
				// frappe.validated = false;
				// reject();
			
			// This will continue to save
				// var negative = 'frappe.validated = false';
				// resolve(negative);

			// If you comment all of it
			// Save button will be disabled (like it still processing)
		})
	},

Here my working function you can use, although i’m using it on before_save hooks

Hi @antzforwork, thanks for answer.
I have solved this during this morning by “Promise” as you mentioned.
I found solution here:

Thank you very much.

1 Like