Cur_frm.cscript.refresh will hide custom button?

Hi,

Just wondering why cur_frm.cscript.refresh is making custom_button hidden.

Was trying to hide custom if doctype meet certain condition, but cant make it because of this issue.

Doctype : Material Request

Script:

cur_frm.cscript.refresh = function(doc, dt, dn){

    /*if (doc.docstatus==1 && doc.workflow_state=="Approved") {
                cur_frm.clear_custom_buttons()
    }*/

}

This might have to do with what’s generating the button. I think if you just do cur_frm.refresh you will be refreshing the form, but not the whole page so it won’t get rid of the button. You can also try frm.refresh. Hope that helps!

Hi, thanks for reply

It works when i change cur_frm.cscript.refresh to cur_frm.cscript.custom_refresh.

Although i’m not really clear what are different between these two.:smiley:

You have to regenerate the buttons on each refresh. This is because those buttons depend on the state of the form and instead of regenerating them on every trigger, they are regenerated on refresh.