When managing customer relations, tracking the number of touches in leads is crucial in optimizing your sales process. A touch refers to any interaction between your sales team and a potential customer. This includes phone calls, emails, tasks, and other exchanges. The number of touches can help you identify which leads are worth pursuing and which may need more time and resources. For example, if a lead has been contacted multiple times but has yet to make a purchase, it may be time to revisit your approach. On the other hand, if you've only reached out to a lead once or twice, it may be worth investing more time and resources into nurturing that relationship. Presently, there is no readily available solution for viewing this crucial metric on your CRM.
However, you can create a custom function and connect it to a workflow rule to display the number of touches each record undergoes in the leads module. 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 record the total number of times a lead record is interacted with before conversion. Learn more
- Create a workflow rule for the Leads module that triggers 10 minutes after the time in the Last Activity Time field. 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. "Touches") 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 Leads from the module dropdown list.
- Provide a name for the rule. For example: "Count the number of touches".
- Add a description (optional), then click Next.
- In the Execute this workflow rule based on section, do the following:
- Choose Date/Time Field, then select Last Activity Time from the dropdown.
- Set the Execution time as 10 minutes after the time in Last Activity Time field.
- Click Next.
- In the Which leads would you like to apply the rule to? section, select All Leads and 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 Leads - Lead Id and name it as leadId, then click Save.
- Click Save & Execute Script.
- Click Save on the workflow rule page.
The code
//Find leads by ID
theLead = zoho.crm.getRecordById("Leads",leadId.toLong());
leadName = "Name: " + theLead.get("First_Name").toString() + " " + theLead.get("Last_Name").toString();
info leadName;
//Count emails sent
leadEmails = zoho.crm.getRelatedRecords("Emails","Leads",leadId);
leadEmailsCount = leadEmails.size();
info "Emails: " + leadEmailsCount;
resp = zoho.crm.getRelatedRecords("Emails","Leads",leadId,1,10,{"type":1});
elist = resp.get("email_related_list");
count = elist.size();
info count;
//Count calls made
leadCalls = zoho.crm.getRelatedRecords("Calls","Leads",leadId);
leadCallsCount = leadCalls.size();
info "Calls: " + leadCallsCount;
//Count tasks completed
leadTasks = zoho.crm.getRelatedRecords("Tasks","Leads",leadId);
//Builds a JSON list of tasks and counts those that are completed
leadTasksList = leadTasks.toJsonList();
taskStatusList = list();
//Displays list of all task statuses (optional)
leadTasksCount = 0;
for each task in leadTasksList
{
taskStatus = task.getJson("Status");
taskStatusList.add(taskStatus);
//Lists all task statuses (optional)
if(taskStatus == "Completed")
{
leadTasksCount = leadTasksCount + 1;
}
}
//info taskStatusList;
info "Completed Tasks: " + leadTasksCount;
//Calculate all outbound touches
outboundTouches = leadEmailsCount + leadCallsCount + leadTasksCount;
info "Outbound Touches: " + outboundTouches;
//Update the total count in the touches field
update = zoho.crm.updateRecord("Leads",leadId,{"Touches":outboundTouches});
info update;
Notes
- Make sure to use the accurate API names for their corresponding fields in the code snippet (e.g. "Touches"). Learn more
- This function will count the number of emails sent to leads via workflow rules in your CRM account.
- The above code is an example of calculating the number of touches in lead records. You can use this code for any other 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 the Leads module.
- Open a lead record to view its details.
- On the Lead Details page, click Send Email to send a test email to the lead.
The workflow rule will be triggered. - Check whether the Touches field reflects the number of interactions for the lead.
Ensure the field updates with the correct number of touches by completing a task or making a call from the record.
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
- ComplexityHigh
- Implementation Time60 minutes

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