How to add a custom button in the list view

Hello guys

I need to add a button in the sales invoice list view and when clicking that according to one field the list view wants to show in ascending or
in descending order.

Is there any option? Please help me with this

1 Like

Hello @jinsy

I’m not too sure about the ordering of the list view, but I do know how to add a button to the list view:

Create a custom script for the Doctype, and select List View.

In the script editor, add these lines of code

function ButtonFunction(listview) {
     console.log("ButtonFunction");
     frappe.msgprint("ButtonFunction");
}
 
frappe.listview_settings['Your DocType Name'] = {
    refresh: function(listview) {
        listview.page.add_inner_button("Button Name", function() {
            ButtonFunction(listview);
        });;
    },
};
3 Likes

@EugeneP Thank you .I will try

Hello @EugeneP,
I added a button “Export” to “Attendance” Doctype for List View.

How can I add the function to export Button so that It should work same as button below.

Inspect and look at the networks to see what api is being called while clicking on the default export button.
Then call that same api using the frm.call method (or an ajax get method) on clicking the custom button.