Add new doctype on create button

I want to add my newly created doc in this dropdown.

WhatsApp Image 2024-10-03 at 1.18.51 PM

  1. Go to Client Script > Add New Client Script.

  2. Fill the Client Script and save it.

Name=Opportunity-Form
DocType=Opportunity
Apply To=Form
Enabled=Check.

And put the lines below in Script.

frappe.ui.form.on('Opportunity', {
    refresh(frm) {
        if (!frm.is_new() && frm.doc.__onload && !frm.doc.__onload.is_customer) {
            frm.add_custom_button(__("Your Custom Doc"), (frm) => {
                //just put your creation code here
                frappe.msgprint("Your creation code goes here");
            }, __("Create"));
        }
    },
})
  1. Just go to your Oppotunity form and refresh it.

Please check the reference: How open new doc with all data in object - #2 by NCP

VIdeo reference: How open new doc with all data in object - #5 by NCP