Overriding Link "Create New" By Custom Script

To override “create new” of a link field vehicle add the following to custom script / js:

frappe.ui.form.on('Doctype Name', {
	refresh: function(frm) {
		frm.fields_dict.vehicle.new_doc = function(){
			//code here
		};
	}
});

e.g.

3 Likes

@revant_one any hint on how to do the same from a link field in child table?

Try this:

frappe.ui.form.on("Sales Invoice", {
	"onload": function(frm) {
		var f = cur_frm.fields_dict["items"].grid.get_field("item_code");
		f.new_doc = new_item_code;
	}
})

function new_item_code() {
	frappe.msgprint("Huzzah!");
}

Hi there, cant get it to work :frowning:

ERPNext: v8.x.x-beta (242218d) (develop)
Frappe Framework: v8.x.x-beta (5773079) (develop)

Hi, did you find any solution for child table?