It's common for multiple leads to be created for individuals from the same company and location, especially after attending trade shows or exhibitions. It also happens that when one lead rejects your product or service, you can reasonably assume that all leads from their company and location are uninterested. In this case, you must look for all the related lead records in your CRM and update their status as unqualified individually. This task can quickly become overwhelming and take up a lot of time. But what if you need to update the status of all leads from the same company and location in one go?
This scenario is a special requirement and not typical for all customers, so we support it through our low-code tools. A custom function enables you to unqualify all leads associated with the same company and location in one go. Read the section below to learn more.
Permissions and availability
- Users with the Manage Automation permission can create and update workflow rules.
- Users with the Manage Extensibility permission can create custom functions.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Create a workflow rule for the Leads module that triggers every time you update its status to "Not Qualified". Learn more
- Write a custom Deluge function that updates the status of all leads belonging to the same company and location and link it up with the workflow rule. Learn more
- Test the workflow rule in a sandbox before deploying it in your production environment. Learn more
Create a workflow rule
Follow the steps below to create a workflow rule that updates the status of leads:
- Navigate to Setup > Workflow Rules > +Create Rule.
- Select the Module as Leads from the drop-down list.
- Provide a name for the rule. For example: "Update the status of leads from the same company and location".
- Add a description, if required, then click Next.
- In the Execute this workflow rule based on section, do the following:
- Choose Record Action, then select Edit from the dropdown.
- Check the box for Repeat this workflow whenever a Lead is edited.
- Choose Specific field(s) gets modified from the drop-down, then enter the condition "When <Lead Status> is modified to <the value> <Not Qualified>".
Note: You could choose any other status that indicates a lost lead. - Click Next.
- In the Which leads would you like to apply the rule to? section, specify the following conditions, then click Next.
- <Company> <is not empty>
- <State> <is not empty>
- <City> <is not empty>
- Under Instant Actions, select Function and Write your own.
- Provide a Name and description, if required, for the function.
- On the Deluge Script Editor, do the following:
- Copy and paste the code given below.
- Click Edit Arguments.
- Choose Leads - Lead Id, name it leadId, and then click Save.
- Click Save & Execute Script.
- Click Save on the workflow rule page.
The code
leadRecord = zoho.crm.getRecordById("Leads",leadId);
status = leadRecord.get("Lead_Status");
company = leadRecord.get("Company");
state = leadRecord.get("State");
city = leadRecord.get("City");
rellead = zoho.crm.searchRecords("Leads","(Company:equals:"+company+") and (State:equals:"+state+") and (City:equals:"+city+")");
if(rellead.size() > 0)
{
for each rec in rellead
{
info rec.get("id");
recid = rec.get("id");
if(recid != leadRecord)
{
update = zoho.crm.updateRecord("Leads",recid,{"Lead_Status":status});
}
}
}
Notes
- Make sure to use the accurate API names for their corresponding fields in the code snippet (e.g., "Company," "State," "City," etc.). Learn more.
- The script above is an example of updating the status of all leads belonging to the same company and location simultaneously. You can customize this code to update status/stages in other modules, such as Deals, by changing the module, field names, and other parameters.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Click the Leads tab.
- Open a lead record that has an entry for the company name, city, and state fields.
Ensure that one or more leads share the same values for the field mentioned above. Otherwise, create new leads. - Update the lead's status to Not Qualified.
The workflow rule will be triggered. - See whether all lead records with the same company name, city, and state as the original lead were updated to "Not Qualified".
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
- ModuleLeads
- Trigger PointWorkflow 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