Customer Doctype Full Name Changed To First Name and Last Name

Hi There,
I would like to change the default Customer Doctype mandatory Full Name field (customer_name) into separate first_name and last_name fields. Is anyone aware of how I would achieve this without breaking or disrupting other ERPnext processes like sales invoice creation etc? Could a client side concat script on the Customer Doctype solve this issue? Any advice on where and how to place this script would be greatly appreciated. I would like to do this so that I can auto populate the related primary Contact and Address fields so as to speed up customer data entry. Being able to search for a customer by full name would still be very handy.
Best Regards
Rick

Set customer_name field, on change of first_name and last_name field.

Customer could be a company or individual, so first name, last name will work only for individuals. Maybe you can show those fields selectively.

Maybe on change of the first / last name fields, you can change the customer name - example:

frappe.ui.form.on("Customer", "first_name", function(frm) { 
  frm.set_value("customer_name", strip(frm.doc.first_name + " " + frm.doc.last_name));
});
1 Like

I just had time to test your script rmehta and it works great. Thank you so much for your help. I ended up swapping the “first_name”, to “last_name” in the first part as I was getting first_name + undefined as a result in the customer_name field. Thanks again.