MultiSelectDialog Hide Secondary Action Button

I need to perform operations by selecting multiple documents in my doctype. For this, I used the example of ‘frappe.ui.form.MultiSelectDialog’ available in the ‘dialog api’. When I do this, the ‘second action’ (Make $doctype name$ button) feature comes up as default. I don’t want this. How can I hide this button


function TopluOde() {
    new frappe.ui.form.MultiSelectDialog({
        doctype: "Fazla Mesai Formlari",
        primary_action_label: "Öde",

        setters: {
            employee: null,
            ebys_onay_durumu: "Onaylandı"
        },

        date_field: "transaction_date",
        get_query() {
            return {
                filters: { odeme_durumu: ['!=', "Ödendi"], hakedis_secimi_sonuc: ['=', "Ücret Ödemesi"] }
            }
        },
        action(selections) {
            frappe.call({
                method: "erpnext.hr.doctype.fazla_mesai_formlari.events.TopluOdeme",
                args: {
                    "form_listesi": selections,
                },
            });
            if (selections.length > 0) {
                frappe.show_alert({
                    message: __('Seçilen formlar ödendi olarak işaretlenmiştir.'),
                    indicator: 'green'
                }, 5);
                setTimeout(function() {
                    location.reload();
                }, 2500);
            } else {
                frappe.show_alert({
                    message: __('İşlem yapılması için form seçilmemiştir..'),
                    indicator: 'red'
                }, 5)
            };
        },
    });
    

}

Is there anyone to help?

@gelveri

for hiding secondary action button you can try this one:

function TopluOde() {
    new frappe.ui.form.MultiSelectDialog({
        doctype: "Fazla Mesai Formlari",
        primary_action_label: "Öde", // Set your custom label here

        setters: {
            employee: null,
            ebys_onay_durumu: "Onaylandı"
        },

        date_field: "transaction_date",
        get_query() {
            return {
                filters: { odeme_durumu: ['!=', "Ödendi"], hakedis_secimi_sonuc: ['=', "Ücret Ödemesi"] }
            }
        },

        // Define your custom primary action here
        primary_action(selections) {
            frappe.call({
                method: "erpnext.hr.doctype.fazla_mesai_formlari.events.TopluOdeme",
                args: {
                    "form_listesi": selections,
                },
                callback: function(response) {
                    if (response.message) {
                        frappe.show_alert({
                            message: __('Seçilen formlar ödendi olarak işaretlenmiştir.'),
                            indicator: 'green'
                        }, 5);
                        setTimeout(function() {
                            location.reload();
                        }, 2500);
                    }
                }
            });
        },

        // You can keep the "Cancel" action if needed
        // Here, it's just set to close the dialog
        primary_action_label: __("Cancel"),

        action(selections) {
            this.hide();
        },
    });
}

Hello bro @Manav_Mandli
That didn’t work, my friend. all it did was rename my primary button to “cancel”. My secondary button ("make overtime forms) still shows up.

Hi brother @gelveri

// Hide the secondary action button
secondary_action: false,
// Hide the "Cancel" button
primary_action_label: null,

Add this before this function:

action(selections) {
    this.hide();
},

I think it works properly. It disables your primary button and secondary button. I also think you can customize the form field by clicking on the customization form.

Bro, this isn’t working.
I don’t think the “secondary_action: false,” parameter will work under the “frappe.ui.form.MultiSelectDialog” function.

YOUR_OBJECT_NAME.dialog.get_secondary_btn().addClass("hide");

OR

YOUR_OBJECT_NAME.dialog.get_secondary_btn().addClass("disable");
1 Like