Server script response issue

I have written below client script to create a button on the ITEM PRICE page and to use it to interact with server script but it does not have any response when it is clicked

frappe.listview_settings['Item Price'] = {
    onload: function(listview) {
        // Add the Bingo button
        listview.page.add_inner_button(__('Bingo'), function() {
            frappe.msgprint(__('Bingo button clicked!'));

            frappe.call({
                method: 'custom_itemprice_action', // Ensure this matches the API Method name you defined
                callback: function(response) {
                    if (response.message) {
                        frappe.msgprint(__('Response received: ' + response.message));
                    } else {
                        frappe.msgprint(__('No response message.'));
                    }
                },
                error: function(err) {
                    // Handle any errors
                    frappe.msgprint(__('Error: ') + err.message);
                }
            });
        });
    }
};


and this is the server script

def custom_itemprice_action():
    # Your logic here
    return "Successfully returned custom_itemprice_action"

Please remove the code and use it:

frappe.response['message'] = "Successfully returned custom_itemprice_action"

Please check the video for a better understanding.

1 Like

@NCP , I have a complex logic and i want to do it via functions, i have used it as “frappe.response[‘message’] = “Successfully returned custom_itemprice_action”” and it worked but in my case i will be defining more than one function and wanted to learn and get support for using functions

Tough logic you can apply it in the custom app using the doc_events or whitelist method.

In the server script doctype, there is a limitation to using the library because everything is not supported on the server script doctype.

Again if you haven’t checked then please check the video.

1 Like

@NCP ohhh yes i did not know that it has limitations and was thinking that its due to my lack of knowledge, :smiley: . yes via Custom APP it worked perfectly . thank you very much