Notify Task owners on change of ownership

Tasks help organize and manage your sales routines efficiently. Your sales routine might include a set number of tasks. Let's say the prospecting process of all your inbound leads includes 2 tasks - analyzing requirements, sending a quotation. This is followed up by a call. By default, all these activities are assigned to a sales executive who is the lead owner. When this sales executive goes on an unplanned leave, the sales manager reallocates the above tasks to another sales executive. However, the sales person to whom the tasks were originally assigned, remains the lead owner and he/she is expected to resume the process from follow-up call.

By design, when the task is reassigned, all the related emails are sent to the new task owner and there are no in-product alerts to notify the lead owner either. You don't want to leave the lead owner in the dark about the task reassignment, do you? Using this week's custom function, keep the original task owner (the lead owner in this case) notified about the task reassignment with a customized email. This custom function gets triggered whenever the task owner and the one to create the task are different.

Further, you can set a workflow rule in CRM so that whenever the task moves on to the next stage, the original owner of the task gets notified. This helps track the tasks progression. This flexibility ensures all your sales routines are completed seamlessly.

Getting started with the function

  1. Go to Setup > Automation > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Invoice Grand Total". Add a description(optional).
  3. Select the module to be associated as Invoice.
  4. Copy the code given below.
  5. Click "Edit Arguments".
  6. Enter the name as "invoiceId" and select the value as "Invoice Id".
  7. Click Save & Execute Script.
  8. Save the changes.

The Code

taskDetails = zoho.crm.getRecordById("Tasks", input.taskId); 
ownerid = ifnull(taskDetails.get("Owner"),"").get("id"); 
taskowner = ifnull(taskDetails.get("Owner"),"").get("name"); 
taskcreated = ifnull(taskDetails.get("Created_By"),"").get("name"); 
headerMap = {"Authorization":"555289a90fb486ea702236e516ac87b2"}; 
response = invokeurl 
url :"" +ownerid 
type :GET 
//info response; 
uservalue = response.get("users").toJSONList(); 
for each rec in uservalue 
email = ifnull(rec.get("email"),""); 
if ( taskowner != taskcreated ) 
link = "<a href='" + taskId + "' >Task Record</a>"; 
from: zoho.adminuserid 
to: email 
subject: "Email Notification" 
message: "Task ownership has been changed for the " + link + " . Do 
check the " + link + "id for more. " ] 


  • The code is zoho.crm._getRecordById for Version 1.0 of.
  • Change the email address in the 'emailNode' with the address of the task owner.
  • The above code can be used in conjunction with workflow rules. For example: Everytime the task status changes, you can send a notification to the task owner.

Found this useful? Try it out and let me 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