How to call print trigger function in custom button of doctype

How to call print trigger function in custom button of doctype, yes it is attach on tool bars but my customer wanted this in a custom button.

No one has answer…?

Try: cur_frm.print_doc()

1 Like

Thanks rmehta it is working fine

here is my code
//For print button
cur_frm.add_custom_button(‘Print’).on(‘click’, function(event) {

        cur_frm.print_doc();
    });
1 Like

Can we also pass the print format name somehow to print_doc()?

its not working for me .
I am getting this error

Traceback (most recent call last):
File “/Applications/erpnext-8.9.1-0/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/app.py”, line 60, in application
response = frappe.handler.handle()
File “/Applications/erpnext-8.9.1-0/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/Applications/erpnext-8.9.1-0/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/Applications/erpnext-8.9.1-0/apps/erpnext/htdocs/frappe-bench/apps/frappe/frappe/init.py”, line 922, in call
return fn(*args, **newargs)
TypeError: runserverobj() takes at least 1 argument (1 given)

Have a found any solution? I have same error as mentioned by Aniket_Shinde1. Kindly tell me where to place the handler code for new button of Doctype.

@Sibghat try this:

frm.print_doc()

Don’t use cur_frm, it is deprecated

1 Like

Thanks for quick response, but i don’t know where to write the code for buttons handler. I tried in my custom .js file, .py file but nothing happened.

did you find a way to do this? passing print format name ?

I am sorry I won’t be able to help since I haven’t used frappe for the last two years or so. I was using it for a project which has been completed. Hope someone can answer this.

@neerajvkn have you got solution?

not exactly, i did find a workaround though. This is my own post about that.