Adding more option under Created Custom Button

Hello,

I had created a new doctype as per requirement so now using custom script I had created a button named as create.
Now what we are looking for is when user click on create button it should list drop down button should have option like (Sales Invoice, Payment and many more option)
How can we achieve this?

Hey @kalepranali044 did you checked the official documentation Frappe Buttons??
Maybe you can check it first.
The example in the official documentation is dropdown button :smirk:, so you can copy paste it!

https://frappeframework.com/docs/v13/user/en/guides/app-development/adding-custom-button-to-form

@antzforwork I tried but it gave me syntax error

Umm did you already change the “User” to your new doctype?
Did you already delete the ?

Or maybe can you share the code here?

@antzforwork

frappe.ui.form.on(“doctypename”, “refresh”, function(frm) {
frm.add_custom_button((“Create”), function() {
frm.add_custom_button(
(‘Sales Order’), function(){
}, __(“Create”));
)
});

No no, the function is after custom button is for firing the code.
So you can do it like this:

frappe.ui.form.on("doctypename", "refresh", function(frm) {

   frm.add_custom_button(__('Button1'), function(){
       //add your function button1 here
		console.log("button 1 function");
	}, __("Grouping"));
	frm.add_custom_button(__('Button2'), function(){
        //add your function button2 here
		console.log("button 2 function");
    }, __("Grouping"));

});
1 Like

@antzforwork It worked.
So basically now whenever user click on button 1 it will create a new entry in sales Invoice
Let says if I click on button 1 it is sales invoice so how can I redirect it as a new entry in sales invoice
Below is the code

frappe.ui.form.on(‘Doctypename’,“refresh”, function(frm) {
frm.add_custom_button(__(‘Sales Invoice’), () => this.make_sales_invoice(), __(‘Create’));
});
make_sales_invoice() {
frappe.model.open_mapped_doc({
method: “erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice”,
frm: this.frm
})
}

I tried the code it is giving me error