Hide Action Menu Item

Hello,

I have following Actions menu defined in workflow:

image

Based on workflow_state, I want to hide either one of the menu item i.e. “Prepared MAF” or “Prepared MAF SCS”. Tried both of the code blocks below:

frappe.ui.form.on(‘DPP Demo WF’, {
refresh: function(frm){
if(frm.doc.workflow_state===‘Preparing MAF/Check Sheet’){
// alert(frm.doc.amended_from);
if (frm.doc.amended_from){
alert(“hide maf”);
frm.page.actions.find(‘[data-label=“Prepared MAF”]’).parent().parent().hide();
} else{
alert(“hide scs”);
frm.page.actions.find(‘[data-label=“Prepared MAF SCS”]’).parent().parent().hide();
}
}
}
})

frappe.ui.form.on(‘DPP Demo WF’, {
refresh: function(frm) {
if (frm.doc.workflow_state === ‘Preparing MAF/Check Sheet’) {
// Check if the current document is an amendment of another document
if (frm.doc.amended_from) {
alert(“hide maf”);
$(‘[data-label=“Prepared MAF”]’).parent().parent().remove();
} else {
alert(“hide scs”);
$(‘[data-label=“Prepared MAF SCS”]’).parent().parent().remove();
}
}
}
});

But nothing works.

1 Like

Reference:

Closed.

2 Likes