How to manage files for frappe.listview_settings script inside the custom app?

I have tried inserting {doctype}_list.js like public/js/{doctype}_list.js inside custom app.
Also applied in hooks.py using app_include_js and doctype_js. But still didn’t work.

It only works when done within the application page.

Here my client Script.

frappe.listview_settings['Opportunity'] = {
    button: {
        show: function(doc) {
            return true;
        },
        get_label: function(doc) {
            return __("Comments");
        },
        get_description: function(doc) {
            return __('Show comments of {0}', [doc.name]);
        },
        action: function(doc) {
            get_comments(doc);
        }
    }
};

get_comments = function(doc) {
    var message_display = "";
    frappe.call({
            method: 'get_comments',
            args: {
                parent_docname: doc.name,  // Pass the name of the parent document
            },
            callback: function(r) {
                if (r.message) {
                    console.log(r)
                    // Process the data from ChildType here
                    var childData = r.message;
                    console.log(childData);
                    message_display = message_display+ "<div>";
                    
                    for (var i = 0; i < childData.length; i++) {
                        var dt = childData[i];
                        message_display = message_display + "<p><b>" + dt.added_on.substring(0,19) + "</b> " + dt.note + "</p>";
                    }
                    
                    message_display = message_display+ "</div>";
                    
                    frappe.msgprint(message_display, 'Comment list with opportunity (' + doc.name + ')')
                    
                }
            }
    });
    
};

My server script.

parent_docname = frappe.form_dict.parent_docname;
data = frappe.db.sql("select `note`, `added_on` FROM `tabCRM Note` where parent = '"+ parent_docname +"'", as_dict=True)
frappe.response['message'] =data

It’s perfect. then bench build and migrate the site.

Then reload and check it.

Thank You!

@NCP Where to insert the server script inside the farppe folder?

Not working @NCP

{custom_app}.py = server script code inside the custom app module

add in custom app hook.py

doctype_list_js = {"Your DocType" : "public/js/your_doctype_list.js"}
1 Like

Thanks!!