How to remove/hide a workflow action button from the form's action menu?

Hello, this code works on the list view:

var edit = listview.$page.find(`[data-label='Edit']`);
edit.hide();
edit.parent().hide(); 
edit.parent().parent().hide();

The button I need to remove/hide is a workflow action button in form:

quita

I tried this code:

var quitar = frm.page.actions.find(`[data-label='Quitar']`);
quitar.hide();
quitar.parent().hide(); 
quitar.parent().parent().hide();

but it doesn’t work.

Thank you in advance.

Hi @VictorHugo99,

Please try it.

frm.page.actions.find('[data-label="Quitar"]').parent().parent().remove();

Then reload and check it.

Thank You!

1 Like

Thank you for your response, but this code doesn’t work for me.

use this

frappe.ui.form.on('Doctype', {
    refresh: function(frm) {
        frm.$wrapper. Find('.actions-btn-group .dropdown-menu li a: contains("action_name")').parent().addClass('hidden');
    }
});
2 Likes

Thank you for your response.
I tried this code:

	refresh: function(frm) {
		frm.$wrapper.find('.actions-btn-group .dropdown-menu li a:contains("Quitar")').parent().addClass('hidden');

but it didn’t work.

Hi @VictorHugo99,

It worked on my side in version-14.
I applied in lead doctype to remove the help option from action button.

Before:

After:

Code:

frappe.ui.form.on('Lead', {
	refresh: function(frm) {
	    setTimeout(() => {
	        frm.page.actions.find('[data-label="Help"]').parent().parent().remove();
	    }, 500);
	}
});

Thank You!

5 Likes

After including the setTimeout function, the code worked. It seems that I was trying to remove the button before it was loaded.

Thank you very much for the help.

This is not working for me. I am using

Frappe Framework: v14.37.1 (version-14)

1 Like

check it and set it.

Then reload and check it.

If not worked then increase time.

1 Like

This works:

frm.page.actions.find(‘[data-label=“Help”]’).parent().parent().remove();

This is not:

frm.page.actions.find(‘[data-label=“Prepared MAF SCS”]’).parent().parent().remove();

Difference:

Help
is standard action

Prepared MAF SCS
is custom action from Workflow Actions

1 Like

Hello, it may not be working due to spacing, try this:

[data-label="Prepared%20MAF%20SCS"]

If it doesn’t work, you need to inspect the data-label of the button using the browser’s inspector.

It works! Thanks!

1 Like

For listview this not working

frappe.listview_settings['Sault'] = {
    onload: function(listview) {
        setTimeout(() => {
            listview.page.actions.find('[data-label="Edit"]').parent().parent().remove();
        }, 500);
    }
};