0

I'm creating custom-buttons in a Client Script. This code works:

// Buttons do appear, everything is fine
frappe.ui.form.on('Article', {
    refresh(frm) {
        frm.add_custom_button("Hello", () => { 
            msgprint("Hello");
        }, "Greet");
        frm.add_custom_button("Ciao", () => { 
            msgprint("Ciao");
        }, "Greet");
}

Then I thought about creating the buttons outside the events with cur_frm, which doesn't work. Why is this so?

// Buttons don't appear
cur_frm.add_custom_button("Hello", () => { 
    msgprint("Hello");
}, "Greet");
cur_frm.add_custom_button("Ciao", () => { 
    msgprint("Ciao");
}, "Greet");
4

1 回答 1

0

cur_frm is deprecated API. Why can't you use frm from one of the JS event methods?

于 2021-07-31T11:45:52.913 回答