From 7cea59d9051fb8fbb1bac005a5b860141bcd00de Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 23 Apr 2024 20:37:57 +0530 Subject: [PATCH] fix: from_name fix for lead --- crm/api/whatsapp.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crm/api/whatsapp.py b/crm/api/whatsapp.py index a6d75948..4585bb83 100644 --- a/crm/api/whatsapp.py +++ b/crm/api/whatsapp.py @@ -123,9 +123,13 @@ def get_whatsapp_messages(reference_doctype, reference_name): # If the replied message is found, add the reply details to the reply message doc = frappe.get_doc(reply_message['reference_doctype'], reply_message['reference_name']) from_name = replied_message['from'] - for c in doc.contacts: - if c.is_primary: - from_name = c.full_name or c.mobile_no + if doc.get("contacts"): + for c in doc.get("contacts"): + if c.is_primary: + from_name = c.full_name or c.mobile_no + break + else: + from_name = doc.get("first_name") + " " + doc.get("last_name") if replied_message: message = replied_message['message'] if replied_message['message_type'] == 'Template':