Avoid duplicate record in Contacts and Accounts during Lead conversion with Custom Function

Avoid duplicate record in Contacts and Accounts during Lead conversion with Custom Function

Hi Experts,
I having problem with custom function "zoho.crm.covertlead" command in my script.
I have a Lead A record about to convert, and the Contacts A is exist in the record.
During the Lead Convert it will auto generate become Contacts B but instead of become Contacts A. 
I did using the searchRecord to check and update the same, but still not working very well.
What i wish to achieve is when record is exist in Contacts A, during the convert lead, it will update on the same record in Contacts to avoid any duplicates.  If this cannot be done, please advise other workaround method?

Please kindly refer to my script:

convert = zoho.crm.convertLead(leadId,{"overwrite":true,"notify_lead_owner":false,"notify_new_entity_owner":false});
info "lead convert : " + convert;
//   Account name, auto pick Full_Name if Company name was empty
if(leadDetails.get("Company").Size() > 0)
{
Accname = leadDetails.get("Company");
}
else
{
Accname = leadDetails.get("Full_Name");
}
//
checkcont = zoho.crm.searchRecords("Contacts","(Email:equals:" + leadDetails.get("Email") + ")");
checkacct = zoho.crm.searchRecords("Accounts","(Account_Name:equals:" + Accname + ")");
// Using Full_Name 
if(convert.get("Accounts") == null)
{
// Check Existed Accounts 
if(checkacct.isEmpty() == false)
{
accname = checkacct.get(0).get("id");
info "accname : " + accname;
// Check Existed Contacts
if(checkcont.isEmpty() == false)
{
contname = checkcont.get(0).get("id");
info "Full Name : Exist Accounts & Exist Contacts";
}
else 
contname = convert.get("Contacts");
info "Full Name : Exist Accounts & New Contacts";
            }
update = zoho.crm.updateRecord("Contacts",contname,{"Account_Name":accname});
info "Update : " + update;
dealmap.put("Contact_Name",contname);
dealmap.put("Account_Name",accname);
invcontact = contname;
invaccount = accname;
}
else // To create New Accounts
{
createacct = zoho.crm.createRecord("Accounts",{"Account_Name":ifnull(leadDetails.get("Full_Name"),"")});
info "CreateAcct : " + createacct;
if(checkcont.isEmpty() == false) // Check if Exits Contacts
{
contname = checkcont.get(0).get("id");
info "Full Name : New Accounts & Exist Contacts";
}
else 
            {
contname = convert.get("Contacts");
info "Full Name : New Accounts & New Contacts";
            }
update = zoho.crm.updateRecord("Contacts",contname,{"Account_Name":createacct.get("id")});
info "Update : " + update;
dealmap.put("Contact_Name",contname);
dealmap.put("Account_Name",createacct.get("id"));
invcontact = contname;
invaccount = createacct.get("id");
}
}
else // When Company_Name has value 
{
// Check Exist Accounts
if(checkacct.isEmpty() == false)
{
acctname = checkacct.get(0).get("id");
if(checkcont.isEmpty() == false)
{
contname = checkcont.get(0).get("id");
info "Company Name : Exist Accounts & Exist Contacts";
}
else 
            { 
contname = convert.get("Contacts");
info "Company Name : Exist Accounts & New Contacts";
            }
update = zoho.crm.updateRecord("Contacts",contname,{"Account_Name":acctname});
info "updatet : " + update;
dealmap.put("Contact_Name",contname);
dealmap.put("Account_Name",acctname);
invcontact = contname;
invaccount = acctname;
}
else
{
// Update New Accounts
createacct = zoho.crm.createRecord("Accounts",{"Account_Name":ifnull(leadDetails.get("Company"),"")});
if(checkcont.isEmpty() == false)
{
contname = checkcont.get(0).get("id");
info "Company Name : New Accounts & Exist Contacts";
}
else 
            {
contname = convert.get("Contacts");
info "Company Name : New Account & New Contacts";
            }
update = zoho.crm.updateRecord("Contacts",contname,{"Account_Name":convert.get("Accounts")});
info "Update Account: " + update;
dealmap.put("Contact_Name",contname);
dealmap.put("Account_Name",convert.get("Accounts"));
invcontact = contname;
invaccount = convert.get("Accounts");
}
}
info "InvContact : " + invcontact;
info "InvAccount : " + invaccount;

    • Sticky Posts

    • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

      Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such
    • User Tips: Auto-Create Opportunity/Deal upon Quote Save (PART 1)

      Problem: We use quotes which convert to sales orders but Users / Sales Reps do not create opportunities / deals and go straight to creating a quote. This leads to poor reporting. Implementing this solution improves reporting and makes it easier for users.
    • Custom Function : Automatically send the Quote to the related contact

      Scenario: Automatically send the Quote to the related contact.  We create Quotes for customers regularly and when we want to send the quote to the customer, we have to send it manually. We can automate this, using Custom Functions. Based on a criteria, you can trigger a workflow rule and the custom function associated to the rule and automatically send the quote to customer through an email. Please note that the quote will be sent as an inline email content and not as a PDF attachment. Please follow
    • Function #50: Schedule Calls to records

      Welcome back everyone! Last week's function was about changing ownership of multiple records concurrently. This week, it's going to be about scheduling calls for records in various modules. Business scenario Calls are an integral part of most sales routines.. Sales, Management, Support, all the branches of the business structure would work in cohesion only through calls. You could say they are akin to engine oil, which is required by the engine to make all of it's components function perfectly. CRM
    • Function #37: Create a Purchase Order from a Quote

      Welcome back everyone! Last week, we learnt how to calculate the total number of activities for a lead and further take note of the activity count for particular dates. For instance, from the period of Demo to Negotiation. This week, let's look at a function that lets you create a Purchase Order instantly from a Quote. Business scenario: In any form of business, one of the most important things to do is to document the transactions. Naturally, negotiation, signing an agreement, placing an order,
    • Recent Topics

    • Slow uploads of large files

      I'm wanting to use Workdrive for transferring large images and video (we're talking things from 100MB-5GB). I'm running solo on a 500MBit/sec fiber connection. I'm getting upload speeds to Workdrive of no more than about 1-3Mbytes/sec when going through
    • Notes of Tasks in Zoho CRM

      Hello, Is there a way to filter the Notes that appear on a Task to only show the notes related to that specific Task and not display all the Notes of the objects related to that Task (Accounts, Contacts, Deal, etc). In essence, our team struggles to understand
    • Migrate Your Notes from OneNote to Zoho Notebook Today

      Greetings Notebook Users, We’re excited to introduce a powerful new feature that lets you migrate your notes from Microsoft OneNote to Zoho Notebook—making your transition faster and more seamless than ever. ✨ What’s New One-click migration: Easily import
    • need to upload from airtable to google drive

      I have a zapier zap that automates between airtable and google drive. When a customer uploads a new file into airtable via a client portal interface, zapier uploads that file into a folder linked to that customer's project record. I need to replicate
    • Default Sorting on Related Lists

      Is it possible to set the default sorting options on the related lists. For example on the Contact Details view I have related lists for activities, emails, products cases, notes etc... currently: Activities 'created date' newest first Emails - 'created
    • Custom Modules - Where are Comments??

      In the standard ticket module and in the tasks module, we have an interactive comment box that we can post important details/notes and can tag others if needed. Where is this functionality for Custom Modules? Ideally, custom modules would have very similar,
    • Credit Management: #1 Credit You Owe vs Credits Owed to the Business

      Think about the last time you ordered food online. You might have paid in advance through your card, but you received a $20 refund because your order got delayed or cancelled. In most apps, refunds don't go into the bank account directly; instead, they're
    • Tip #46- Turn Every Session into an Insight with Zoho Assist survey report- 'Insider Insights'

      Delivering exceptional remote support isn’t just about resolving issues, it’s about understanding how both customers and technicians experience each session. That’s where Survey Report in Zoho Assist come in. You can configure and customize survey questions
    • Enhancing Zia's service with better contextual responses and article generation

      Hello everyone, We are enhancing Zia's Generative AI service to make your support experience smarter. Here's how: Increased accuracy with Qwen One of the key challenges in AI is delivering responses that are both contextually accurate and empathetic while
    • Allow the usage of Multi-Select fields as the primary field on "Layout Rules"

      We want to force our users to enter some explanation strings when a multi-select field has been utilized. I can't understand the reason for the usage restriction of Multi-Select fields as a primary field. This is a simple "Display hidden mandatory field
    • Engage with your customers at scale using WhatsApp Marketing Template messages

      Hi everyone, To make it easier for organizations to communicate with customers, Desk now allows you to send individual, mass, and bulk WhatsApp template messages from both the Ticket and Contact modules. How is this going to benefit your business? WhatsApp
    • CRM/Bookings integration edits Contact names

      Hi there, I've installed the extension that connects Zoho CRM and Zoho Bookings. When we get a new appointment from Bookings from an existing Contact, that Contact's record shows this: First Name was updated from asd to blank value Last Name was updated
    • Domain Change

      “Please update my Email-in domain from @biginmail.biginmail.in to @biginmail.zoho.com. Messages to the .in domain are bouncing.”
    • Edit 'my' Notes only

      The permissions around Notes should be more granular, and allow to user to be able to edit the notes he created only. The edit Notes permission is useful as it allows the user to correct any mistakes or add information as needed. However, with this same
    • Webhooks Limit Exceeded

      Today, I received an error message saying, 'Total number of Webhook call exceeded', but when I look at Manage > Billing, it doesn't look like any of my invokeURL calls are being logged. Following the advice from this thread: https://help.zoho.com/portal/en/community/topic/webhooks-daily-limits-in-zoho-creator
    • why cant i access my email account. it keeps asking me for reverifiying my account by entering my password.

      I cant access my account. it keeps asking me for reverifcaton by entering my password. once its entered it asks for it over and over.
    • Option to block bookings from specific email address or ip adresss in zoho booking

      Sometime few of our client keep booking irrelevant booking service just to resolve their queries and they keep booking it again and again whenever they have queries. Currently its disturbing our current communication process and hierarchy which we have
    • Auto select option in CRM after Zoho Form merge

      Hi, I have a dropdown field in Zoho CRM that is filled with a Zoho Form. The data is filled but not automatically shown. After selecting the right value in the dropdown the information a second field is shown. So the question is; how can I make the dropdown
    • Option to Customize Career Site URL Without “/jobs/Careers”

      Dear Zoho Recruit Team, I hope you are doing well. We would like to request an enhancement to the Career Site URL structure in Zoho Recruit. In the old version of the career site, our URL was simply: 👉 https://jobs.domain.com However, after moving to
    • Using IMAP configuration for shared email inboxes

      Our customer service team utilizes shared email boxes to allow multiple people to view and handle incoming customer requests. For example, the customer sends an email to info@xxxx.com and multiple people can view it and handle the request. How can I configure
    • スマホでキャンペンメールを見ると正しく表示されない

      キャンペーンのメール(HTML)を作成しましたが、スマホ表示に切り替えると正しく表示されません(添付参照)過去に作成したキャンペーンでは特に意識してませんでしたが、問題なく表示されていたようです。うまく表示される場合とされない場合の違いは何でしょうか?
    • Bring your CRM data straight into your presentations in Zoho Show

      Let's say you are working on a presentation about your team's sales pipeline for an upcoming strategy meeting. All the information you need about clients and leads is in Zoho CRM, but you end up copying details from the CRM into your slides, adjusting
    • Improved RingCentral Integration

      We’d like to request an enhancement to the current RingCentral integration with Zoho. RingCentral now automatically generates call transcripts and AI-based call summaries (AI Notes) for each call, which are extremely helpful for support and sales teams.
    • Introducing New APIs in Zoho Contracts

      We are excited to announce the release of new APIs in Zoho Contracts to help you automate and manage every stage of your contract lifecycle more efficiently. Here’s a quick overview of what’s new: 1. Complete Contract Draft You can use this API to complete
    • Vimeo

      For me Vimeo is the most important video social channel for media and filmmakers. Would others agree and like it added to Zoho Social.
    • Delete a department or category

      How do I delete a Department? Also, how do I delete a Category? This is pretty basic stuff here and it's impossible to find.
    • Organization Emails in Email History

      How can I make received Org Emails to show up here?
    • Create custom rollup summary fields in Zoho CRM

      Hello everyone, In Zoho CRM, rollup summary fields have been essential tools for summarizing data across related records and enabling users to gain quick insights without having to jump across modules. Previously, only predefined summary functions were
    • Editing the Ticket Properties column

      This is going to sound like a dumb question, but I cannot figure out how to configure/edit the sections (and their fields) in this column: For example, we have a custom "Resolution" field, which parked itself in the "Ticket Information" section of this
    • Deleting Fields in CRM Deletes Views in Analytics

      Hey friends! I'm having some issues when we modify some fields within ZohoCRM. There are times where we need to sunset a field and eventually completely remove it. In these instances, it seems like a lot of views are removed in Analytics. This ranges
    • Zoho Analytics Automatically Deletes Queries and Reports When a Synced CRM Field Is Removed

      We’ve encountered a serious and recurring issue that poses a massive data integrity risk for any Zoho Analytics customer using Zoho CRM integration. When a field is deleted in Zoho CRM — even an unused one — Zoho Analytics automatically deletes every
    • How to setup pricing in Zoho

      Hi everyone, I am relatively new here and have just moved from my old inventory system to the Zoho one. I am trying to get my head around how it all works. I am mostly setup connected to a shopify store, but I do manual sales also For manual invoicing,
    • Introducing the revamped What's New page

      Hello everyone! We're happy to announce that Zoho Campaigns' What's New page has undergone a complete revamp. We've bid the old page adieu after a long time and have introduced a new, sleeker-looking page. Without further ado, let's dive into the main
    • Workaround: openURL in Blueprints - An alternate approach

      There is a roundabout way to open a URL in blueprints after a save event. By using the 'onBeforeMandatoryFormSave' in Client Script, you can open an external URL. Now, the problem is, this is designed to be run BEFORE the blueprint is saved, not after,
    • Prefilled Date fields auto-changed and then locked when using “Edit as new”

      If a document out for signature has date fields (not SignedDate fields) that were pre-filled before sending, and then you use “Edit as new” to create a new version of the same document, the value of those date fields gets automatically changed to today
    • Is there a way to update all the start and end dates of tasks of a project after a calendar change?

      Hi! Here's my situation. I've built a complete project planning. All its tasks have start dates and due dates. After completing the planning, I've realized that the project calendar was not the right one. So I changed the project calendar. I now have
    • Access Phone Field Components (Country Code) Directly

      Hello everyone, I'd like to propose an enhancement for the Phone field in Zoho Creator. The Problem: The Phone field captures the country code and local number separately, but stores them as a single string (e.g., +1234567890). To get the country code,
    • Send mass messages through WhatsApp from the Tickets module

      Hi Everyone! Effective communication is key to delivering prompt and reliable customer support. Because WhatsApp is one of the most widely used and familiar messaging platforms, it's an effective channel for agents to reach customers who have submitted
    • Zoho Desk iOS and Android app update: AI powered: Reply Assistance and Refine Messages on IM module.

      Hello everyone! We are excited to introduce new AI powered features on the IM module of the Zoho Desk app. Reply Assistance: Reply Assistance generates suggested responses for incoming chat messages, which you can directly insert into the conversation
    • The difference between Zoho Marketing Automation and Zoho Campaigns

      Greetings Marketers! This post aims to differentiate between Zoho Marketing Automation and Zoho Campaigns. By the time you get to the end of the post, you will be able to choose a product that objectively suits you. What is Zoho Marketing Automation?
    • Next Page