Override a JavaScript function from the client script

Hello, I’m using the Lead doctype and it looks like if I don’t enter the lead_name, it will fetch the name from the organization name field as shown in the code from erpnext/lead.js at develop · frappe/erpnext · GitHub

	company_name () {
		if (!this.frm.doc.lead_name) {
			this.frm.set_value("lead_name", this.frm.doc.company_name);

This method will override every try to make the lead_name empty. So is there a way to override or remove the defualt function to run.

Hi @Mohsin1990,

Only one way to remove lead_name like if Lead is an Organization
Please apply it.

frappe.ui.form.on('Lead', {
	    if(frm.doc.organization_lead == 1) {
	    frm.set_value("lead_name", " ");

Then reload and check it, please.

Thank You!

Tried this solution but there is a new error for the contact

because you enter the contact details and contact details for first name (lead_name) are Mandatory.
remove contact details and check it.

I only entered the company name which is mandatory but still the same error as the company will be linked to the contact name.

Hmm, Right.

Sometimes work and sometimes does not work on my side.

Sometimes organization name is set in the first name in a contact form.