Set options for linked doctypes

Hi everyone,

I have two doctypes i.e first and second doctype, both with a name field, the name field is the naming series, the first doctype has a ‘next section’ button. I want to set route when this button is clicked, such that;

  1. In the first option, from the first doctype it can open a new form of the second doctype.i.e new second 1
    2.else it opens a second doctype form with a similar name to the first doctype.

Thanks

Try this code.

frappe.ui.form.on("First Doctype Name",{

	refresh: function(frm) {
		add_button(frm);
	}
});

var add_button = function(frm) 
{
		frm.add_custom_button(__("Send Data"), function() {
			frappe.route_options = {
				"first_name": frm.doc.first_name
				
			},
			
			frappe.set_route("Form", "Second Doctype Name" , "New Second Doctype Name");
		});
}
1 Like

Thanks Shahid