[Tutorial] How to Override Custom Button Behavior inside Standard Doctype

Hello Guys i faced this problem and there was no direct solution for it. so i did work around for it.
1 - In Doctype Custom Script form refresh evernt remove the button you want to override using

// remove custom button
frm.remove_custom_button('Quotation');

// remove custom button in a group
frm.remove_custom_button('Quotation', 'Create');

2- add new custom button as it`s old name

// Custom buttons
frm.add_custom_button('Open Reference form', () => {
     // put your logic here 
})

// Custom buttons in groups
frm.add_custom_button('Quotation', () => {
    // put your logic here 
}, 'Create');

finally you are done ^ ^

3 Likes

For whatever reason, my button wont come off

script

frappe.ui.form.on('Sales Order', {
    refresh(frm){
        frm.remove_custom_button('Hold', 'Status');
        console.log('my refresh')
    },
});

There is “Hold” under Status button group. console shows that the code is running.

Ok, this works

frappe.ui.form.on('Sales Order', {
    onload_post_render(frm){
        frm.remove_custom_button('Hold', 'Status');
        console.log('my refresh')
    },
});
1 Like