Auto-update tasks with details from related record modules.

Business scenario

Tasks in Zoho CRM helps organize your to-do-lists efficiently. It not only helps keep a tab on your to-do-lists, but also enables easy access to related record in other modules. This for sure, makes you productive. What if I say there is a possibility of taking this one step ahead? While Tasks enables easy access to related records associated with the task records, won’t it be great if it were to fetch all the required information from the related record modules to complete the task?

Such a possibility cuts down on the need to loop between the task record and the related record module - say for example between the lead record and the associated task record. This week’s function helps you do just that. It auto-updates the custom fields in task records with required details from the related record modules.

Pre-requisites

  • As functions are module specific, you need to update the appropriate function individually for the respective modules that require the auto-update functionality. We have covered four use cases with certain important fields in the below code. For instance, the code shared for Leads module auto-updates the State and Phone number details from the Leads module on the task record's custom fields. Choose the ones that fits your sales process and update the required field parameters accordingly.
  • Add the required custom fields in the Tasks Layouts. Go to Setup > Customization > Module and Fields > Tasks > Layouts, drag and drop the required custom fields. The details fetched from the respective record modules gets updated in these custom fields.
 

Getting started with the function

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Auto Update Tasks from related lists".
  3. Select the moduleto be associated as Tasks. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "taskId" and select the value as "Task Id".
  7. Enter the name as "phone" and select the value as "Phone".
  8. Click Save & Execute Script.
  9. Save the changes.
 

The Code


taskDetails = zoho.crm.getRecordById("Tasks", input.taskId.toLong()); 
//info taskDetails; 
whatid = ifnull(taskDetails.get("What_Id"),""); 
whoid = ifnull(taskDetails.get("Who_Id"),""); 
if( whatid != "") 
{ 
recordid = ifnull(taskDetails.get("What_Id"),"").get("id")'' 
module = ifnull(taskDetails.get("se_module"),""); 
getDetails = zoho.crm.getRecordById(module, whatid); 
timezone = ifnull(getDetails.get("Time_Zone"),""); 
mp=map(); 
mp.put("Time_Zone",timezone); 
update = zoho.crm.update("Tasks", taskId, mp); 
info mp; 
info update; 
} 
if( whoid != "") 
{ 
contid = ifnull(taskDetails.get("Who_Id"),"").get("id"); 
getDetails = zoho.crm.getRecordById("Contacts", contid); 
timezone = ifnull(getDetails.get("Time_Zone"),""); 
mp=map(); 
mp.put("Time_Zone",timezone); 
update = zoho.crm.update("Tasks", taskId, mp); 
info mp; 
info update; 
}

Note:

  • 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!

Return to Tips