Salespeople often find it challenging to establish a connection with leads, even after scheduling multiple calls over several days. In such cases, the chances of these leads showing interest or converting are minimal. By removing these unproductive leads, your sales team can concentrate on more promising prospects and increase their chances of success. The most efficient way to remove unreachable leads is by marking them as junk. Marking leads as junk automatically can help keep your database clean and organized. You can mark leads as junk in CRM automatically using a custom function.
With a custom function, leads can be marked as junk automatically after five unanswered outbound calls that last less than 10 seconds. You can achieve this by updating a custom field in the lead record to track call counts. Additionally, if the call gets answered after three failed attempts, the call count resets to zero. This helps you have more precise control over which leads are marked as junk in your CRM. Read the section below to learn more.
Permissions and availability
- Users with the Modules Customization permission can add custom fields.
- 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
- Add a Number field in the Leads module. This field will hold the number of unanswered outbound calls to the lead record. Learn more
- Create a workflow rule for the Calls module that triggers every time an outgoing call is logged or modified. Learn more
- Write a custom Deluge function and link it up with the workflow rule. Learn more
- Test the workflow rule in a sandbox before deploying it to your production environment. Learn more
Add a custom field
The first step is adding the custom number field to the Leads module.
- Navigate to Setup > Customization > Modules and Fields.
- Click the Leads module to open the layout editor.
- Drag and drop the Number field from the New Fields tray to the desired section of the layout.
- Name the number field (e.g. "Number of Sales Call") and define its properties as required.
- Once you have finished, click Save and Close.
Create a workflow rule
- Navigate to Setup > Workflow Rules > +Create Rule.
- Select Calls from the module dropdown list.
- Provide a name for the rule. For example: "Auto Update Leads as Junk".
- Add a description (optional) and then click Next.
- In the Execute this workflow rule based on section, choose Record Action, then select <Outgoing call> is <logged or modified> from the dropdown and click Next.
- In the Which calls would you like to apply the rule to? section, do the following:
- In Would you like to set conditions for call properties?, select No.
- In Apply this rule to, choose Lead.
- In Which contacts would you like to apply this rule to?, select All Leads.
- Click Next.
- Under Instant Actions, select Function and Write your own.
- Provide a name and description, if necessary, for the function.
- On the Deluge Script Editor, do the following:
- Copy and paste the code given below.
- Click Edit Arguments.
- Choose Calls - Call Id and name it as callId, then click Save.
- Click Save & Execute Script.
- Click Save on the workflow rule page.
The code
if(resp.get("Call_Duration_in_seconds") < 10)
{
if(resp.get("$se_module") == "Leads")
{
leadid = resp.get("What_Id").get("id");
leadResp = zoho.crm.getRecordById("Leads",leadid);
val = ifnull(leadResp.get("Number_of_Sales_Call"),0);
val = val + 1;
mp = Map();
mp.put("Number_of_Sales_Call",val);
if(val == 5)
{
mp.put("Lead_Status","Junk Lead");
}
info mp;
upd = zoho.crm.updateRecord("Leads",leadid,mp);
info upd;
}
}
else if(resp.get("Call_Duration_in_seconds") > 10)
{
if(resp.get("$se_module") == "Leads")
{
leadid = resp.get("What_Id").get("id");
mp = Map();
mp.put("Number_of_Sales_Call",0);
upd = zoho.crm.updateRecord("Leads",leadid,mp);
info upd;
}
}
Notes
- Replace "5" with the number of unanswered outgoing calls you wish to attempt before a lead gets marked as junk.
- In addition to updating the lead status, you can customize the code to add a "Junk" tag to filter out such leads in custom list views. Learn more
- Use the accurate API name of the custom URL field in the code snippet (e.g., "Number of Sales Call"). Learn more
- The code above is an example of automatically marking a lead as junk after making a certain number of unanswered outgoing calls. You can use this code for any other module, such as a custom module, by modifying the module name and 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 Calls > Create Call > Log a call.
- In the Log a call pop-up window, do the following:
- Select Lead from the picklist, search for, and select the corresponding lead who received the call.
- Select Call Type as Outbound.
- Specify the Call Duration as 00 minutes 00 seconds (i.e., less than 10 seconds) and click Save.
- Log four additional outbound calls for the same lead again.
- Check whether the Lead's Number of Sales Call field updates the exact count of calls and if its status changes to Junk Lead after the fifth attempt.
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
- ComplexityMedium
- Implementation Time30 minutes

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