Hi , I am trying to remove Print
button from actions menu items in Leave Application
list.
I wrote this code but did not affect Actions items
let actions_list = cur_list.actions_menu_items
for(let j=0; j < actions_list.length; j++){
if (actions_list[j]['label'] === "Print"){
let print_btn_index = actions_list.indexOf(actions_list[j]);
actions_list.splice(print_btn_index, 1);
console.log("Print", print_btn_index);
}
};
nothing changed !
what is the best practice for doing so ?
Hello @mohamed_saif,
Did you find any solution for this, as i am also facing the same problem.
Regards,
Vishakha Mishra
I got the solution. Follow the below code,
$(‘a.grey-link’).each(function() {
var data = $(this).text()
if(data.includes(“Duplicate”)){
$(this).remove();
console.log(“Removed Duplicate Button”)
}
});
Thanks
3 Likes
Excellent idea Taniyavish, that was very helpful. I took the liberty of improving the logic so it also works in multilingual installations:
refresh(frm) {
setTimeout(function() {
// Waiting for ERPNext to render the buttons, only to remove them immediately after
console.debug("Removing Duplicate Button");
$('a.grey-link').each(function() {
// Comparing data-label instead of Button Text
var id = $(this).children(':first-child').attr('data-label');
if(id == 'Duplicate'){
$(this).remove();
return false // exit loop
}
});
}, 100);
}
3 Likes