How to add the custom button on the header of the form?

Hello,

How to add custom button at the header of the form?

I want to add my custom button on highlighted area (left side of the Make button) of the attached screen-shots.

@Chandresh_Thakkar,

You can add the custom button using add_custom_button method from your custom script.

e.g.

frm.add_custom_button("button lable", function() {
	// code to be executed after button is click
}, "Button Group")
1 Like

Hii,

thanks for reply.

Yes its work for me when i add this code in my custom doctype js.

But if i want to add same button in Delivery Note form then what should i do?

You can see in my attached screen-shots.

Thank You.

@Chandresh_Thakkar,

create the custom script for doctype Delivery Note from Setup > Customize > Custom Script

Ok.

Thank You so much.

Hello,

I have created one custom script for delivery note doctype.

This is my code:

frappe.ui.form.on(“Delivery Note”, {
refresh: function(frm) {
// use the __islocal value of doc, to check if the doc is saved or not
frm.add_custom_button(“My Button”, function() {
// code to be executed after button is click
}, “Button Group”)
});

But when i load my site and click on delivery note record, it gives me an error like:

Solved.

Thank You.

is it please possible to explain the solution?
thanks

Yes sure.

I forget to complete } bracket before the last line of my code.

That’s why I got the error. Otherwise, this code has worked for me. :handshake:

1 Like

frm.add_custom_button(“My Button”, function() {
// code to be executed after button is click
}, “Button Group”).addClass(“btn-primary”);
This will make as primary button like Make