How to refresh a doctype once a doctype loaded

How I can call the location.reload() once on load or refresh doctype instead of calling it through the button. My need is to refresh the doctype automatically as components in the tab are not loading but they load once we refresh the page

frappe.ui.form.on('Real Estate Project', {
    refresh(frm) {
    cur_frm.add_custom_button(__("Refresh"), function() {
    location.reload();
    
    }); 
    }
});

Hi @CA_B.C_Chechani,

Please try this.

frappe.ui.form.on('Real Estate Project', {
    after_save(frm) {
        location.reload();
    }
});

Thank You!

Thanks, But I need location.reload() immediately on a load of the doctype. If I call it on “on load” or “on setup” or " Refresh" it works but goes into the loop ( Refreshing again and again)

Use frm.reload_doc()

https://frappeframework.com/docs/v13/user/en/api/form#frmreload_doc

Maybe it will work for you.

Thanks.

Hi @CA_B.C_Chechani,

Refresh page will only be one time.

frappe.ui.form.on('Real Estate Project', {
    refresh(frm) {
        if(!window.location.hash) {
            window.location = window.location + '#';
            window.location.reload();
        }
    }
});

Then reload and check it, please.

Thank You!

1 Like

Thanks a lot! @NCP , We can use the Tabbreak field type now in v14 by refreshing every time ( as we could not identify the reason for not loading components in Details tab