diff --git a/frappe/contacts/doctype/contact/contact.py b/frappe/contacts/doctype/contact/contact.py index 1b314e5c890b..1d9db58f882b 100644 --- a/frappe/contacts/doctype/contact/contact.py +++ b/frappe/contacts/doctype/contact/contact.py @@ -332,13 +332,9 @@ def get_contact_with_phone_number(number): return contacts[0].parent if contacts else None -def get_contact_name(email_id: str) -> str | None: - """Return the contact ID for the given email ID.""" - for contact_id in frappe.get_all( - "Contact Email", filters={"email_id": email_id, "parenttype": "Contact"}, pluck="parent" - ): - if frappe.db.exists("Contact", contact_id): - return contact_id +def get_contact_name(email_id): + contact = frappe.get_all("Contact Email", filters={"email_id": email_id}, fields=["parent"], limit=1) + return contact[0].parent if contact else None def get_contacts_linking_to(doctype, docname, fields=None):