Update the lead records with Notes and Activities count.
On an average how many times should I call a lead before moving on? I’m sure most of you would have faced this dilemma at one point or the other. Effective prospecting takes time and effort. Notes and Activities are important CRM utilities that helps keep a tab of your client interactions. Zoho CRM provides a list of all the activities related to a lead like Tasks, Calls and Events right within your lead records. Keeping a count of the Activities related your lead records does come in handy. What if you want to qualify the lead as Lost after a specific number of calls? However, such data is not readily available inside the lead records. That is where this week’s function comes to the picture. It updates the total count of Notes, Events, Tasks and Calls in corresponding custom fields inside the lead records. Include these fields in your Lead views, sort accordingly to take necessary action.
So, if you are looking for options to sort lead records based on the count of Calls or Events, look no further. This function is tailor-made for you.
- Add the required custom fields in the Leads Layouts. Go to Setup > Customization > Module and Fields > Leads > Layouts, drag and drop the required custom fields. The names of the custom fields are case sensitive. So, names should be 'Notes Count', Task Count', 'Event Count', 'Call Count' and 'Activity Count'. The details fetched from the respective record modules gets updated in these custom fields.
- In the Leads module, click Add Columns and select the created custom field to display in the module. Click the Field name and select Asc or Desc, to sort the leads based on the interaction count.
Getting started with the function
- Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
- Provide a name for the button. For example: "Activity Count". Add a description(optional).
- Select the placement of the button as View page.
- Select the action to be performed as "Writing function".
- Copy the code given below.
- Click "Edit arguments".
- Enter the name as "contactId" and select the value as "Contact Id".
- Click Save & Execute Script.
- Save the changes.
- Select the profiles who can view this button.
- Click Save.
RelatedTasks = zoho.crm.getRelatedRecords("Tasks", "Leads", leadId.toLong()); RelatedEvents = zoho.crm.getRelatedRecords("Events", "Leads", leadId.toLong()); RelatedCalls = zoho.crm.getRelatedRecords("Calls", "Leads", leadId.toLong()); RelatedNotes = zoho.crm.getRelatedRecords("Notes", "Leads", leadId.toLong()); total = RelatedTasks.size() + RelatedEvents.size() + RelatedCalls.size(); mp = map(); mp.put("Task_Count", RelatedTasks.size()); mp.put("Event_Count", RelatedEvents.size()); mp.put("Call_Count", RelatedCalls.size()); mp.put("Notes_Count", RelatedNotes.size()); mp.put("Activity_Count",total); update = zoho.crm.update("Leads", leadId.toLong(), mp); info mp; info update; return "success";
- The above code works only for API V2.0 and not the previous version.
Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!