When adding contacts to your CRM, it is best practice to check if a lead record with the same email address already exists. If a lead with the same email exists, it's better to convert them into a contact rather than creating a new entry. This approach helps avoid duplicate records, simplifies lead conversion tracking, and prevents redundant outreach efforts from your marketing and sales teams. However, manually checking for leads can be tedious for your salespeople. What if there were an automatic duplicate detection mechanism? This is where a custom function coupled with a validation rule can come in handy.
Create a validation rule with a function for the "Email" field in the contacts module. Upon entering the email address, this rule checks whether a lead record exists with the same email address. If existing, it alerts your salespeople to convert the lead instead of creating a duplicate contact. Read on to learn more.
Permissions and availability
- Users with the Module Customization permission can create and update validation rules.
- Users with the Manage Extensibility permission can write custom functions.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Create a validation rule for the Contacts module to validate the email address entered in their Email field. Learn more
- Write a custom Deluge function that checks and alerts salespeople when a lead record shares the same email address as the newly created contact. Learn more
- Test the workflow rule in a sandbox before deploying it in your production environment. Learn more
Create a validation rule
Follow these steps to create a validation rule in your Zoho CRM account:
- Navigate to Setup > Customization > Modules and Fields.
- Select the Meetings module, then click the Validation Rules tab.
- Click Create New Validation Rule.
- In the Create Validation Rule pop-up, perform the following actions:
- Select the layout to which the field you wish to validate belongs.
- Select Email as the field to validate.
- Select the validation type as Using function.
- Select between Save Only or Field Verify and Save under Validate On.
- Click Next.
- In the Configure Function page, click Write your own.
- Enter a Name, Display Name, and a description if needed, then click Create. For example: "Detect leads with the same email".
- In the Deluge Script Editor, do the following:
- Copy and paste the code provided below.
- Click Save.
- Click Save on the validation rule page.
The code
entityMap = crmAPIRequest.toMap().get("record");
email = entityMap.get("Email");
response = Map();
if(email.isNull())
{
response.put('status','failure');
response.put('message','The Email field is empty');
}
else
{
relatedrecords = zoho.crm.searchRecords("Leads","(Email:equals:" + email + ")");
if(relatedrecords.size() == 0)
{
response.put('status','success');
}
else
{
response.put('status','failure');
response.put('message','A lead with the same email address already exists');
}
}
return response;
Notes
- Make sure to use the accurate API names for their corresponding fields in the code snippet (e.g., Email). Learn more
- You can customize the alert message that appears when a lead record shares the same email address.
- The code above is an example of validating a contact's email address to ensure no lead records share the same email address in your CRM, which you could convert instead. You can use this code to validate email fields in any other module by modifying the field name parameters.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Navigate to Contacts > + Create Contact.
- On the Create Contact page, enter all required details, including the email address of an existing lead record, in the Email field, then click Save.
The validation rule will be triggered. - Check whether the alert message, as specified in the code snippet, is displayed under the Email field.
Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.
More info
- ModuleContacts
- Trigger PointValidation Rule
- EditionEnterprise and above
- ComplexityLow
- Implementation Time15 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST