Adding Button in Menu under List View

Trying to add button under Menu dropdown in a Doctype
Tried writing code [doctype_list.js] in Custom App within folder of standard Doctype [Serial No] but the code does not get triggered and no button is added.
Used this as reference

Writing code in the core JS file might break during the update.

Has anyone done this before? Any pointer in right direction?


1 Like

I understand you want to add a custom script to Serial No DocType.

In your custom app (my_app), save your code in the folder my_app/public/js/. For example, my_app/public/js/serial_no.js. The content of this file is your custom script. It would look something like this:

frappe.ui.form.on("Serial No", "refresh", function(frm) {
    frm.add_custom_button(__("Do Something"), function() {
            console.log("Did something");

Then go ahead and tell frappe to serve this file with the Serial No DocType: open your app’s hooks (my_app/ and add your script to the doctype_js or doctype_list_js variables.

# ...
doctype_js = {"Serial No" : "public/js/serial_no.js"}
# ...

Thanks I was missing the step.
Thanks for your help.

You’re welcome! Please mark my answer as solution, if it solved your problem :slight_smile:

I tried, for some reason, I don’t see the option to mark it as a solution. Don’t know why

Weird, usually it should look like this:


Yup it is weird, don’t see that option

the menu already changed as action menu, my working code is as below

frappe.listview_settings[‘Demand Estimate’] = {

onload: function(listview) {"Create Components Demand Estimate"), function() {

        const docnames = listview.get_checked_items(true).map(docname => docname.toString());



            method: 'ddmrp.ddmrp.doctype.demand_estimate.demand_estimate.create_demand',

            freeze: true,

            args: {

                docnames: docnames                  



        .then((r) => {

            let cnt = r.message;

            if (cnt) frappe.msgprint('Created ' + cnt + ' demand estimate records')






it is not working on the list view…or i am doing something wrong ?

Right, my post described adding a custom button to the form view. See the wiki on how to customize the list view: