TKramer
TKramer

Reputation: 3

Frappe: cur_frm.add_custom_button() does not add a Custom-Button

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");

Upvotes: 0

Views: 1603

Answers (1)

Ankush
Ankush

Reputation: 490

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

Upvotes: 1

Related Questions