->I have created a custom DocType “Lead Contact” under module CRM.
->“Lead Contact” is Table under the Lead DocType.
->I’m trying to fetch the “company_name” from Lead and add it “company_name” in Lead Contact.
So my end goal is to make my Leads Organization-centric.
To do this, I have created a new DocType: Lead Contact, which would allow my Sales Reps to add multiple contacts for each lead, and not have to make a new lead for a person in an existing organization.
For this reason, I’m trying to link my Lead Contact to Lead with Organization Name in both. (field name: company_name), so i can fetch the values of the contacts with the Organization Name into contacts via the Customer.py file.
An organization Frappe (Organization Name) is saved as a lead, and the Contact List(Lead Contact Doctype) has the names of the people at Frappe, i.e., Rushabh, Anand, etc.
I want the Organisation under Contact List(Lead Contact Doctype) to be automatically updated with the name of the Organization added in Lead.
That is: Each person like Anand would have Organization Name as Frappe. (The field should be “read-only”, but i’ll do that once i get it to work.)
add a Python Hook event to the Customer based on “before_insert”, and the function will be this.
def before_insert_customer(doc, method=None):
if doc.lead_name:
for contact in frappe.get_all("Contact", {"lead": doc.lead_name}):
frappe.db.set_value("Contact", contact["name"], "lead", self.lead_name)
Every time that you convert a lead to a customer it will track the contacts.
Do you can replace the event to “on_update” for every time too.