Call a standard function using a button

Hi Everyone,
I want to call a standard function on click of a standard button:
Below is my code, but it is giving error:

frappe.ui.form.on("Customer", "browse_bom", function(frm) {
//  frappe.set_route("Form", "Customer", "CustomerName")
frappe.set_route("bom-browser", frm.doc.name);
});

Below is the error:

Traceback (innermost last):
File “/home/sam/frappe-bench/apps/frappe/frappe/app.py”, line 57, in application
response = frappe.handler.handle()
File “/home/sam/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/sam/frappe-bench/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/sam/frappe-bench/apps/frappe/frappe/init.py”, line 806, in call
return fn(*args, **newargs)
TypeError: runserverobj() takes at least 1 argument (1 given)

Can anybody help?

@ruchin78 in this case use

cur_frm.cscript.browser_bom = function(){
  frappe.set_route("bom-browser", frm.doc.name);
}

@max_morais_dmm
Still the same error

Also, I found the working code:

frappe.ui.form.on(“BOM”, “browse_bom”, function(frm) {
frappe.set_route(“bom-browser”, frm.doc.name);
});

It is working fine, thanks

2 Likes