After closing a deal with a potential customer, you may have to conduct a series of activities for them. For example, if you provide broadband services, you must conduct certain activities, such as surveying customer sites, drawing cables, installing equipment, setting up routers, and so on. Furthermore, these activities might not be carried out by a single person. Therefore, it is best practice to use tasks within your CRM to create and monitor them. However, creating and assigning tasks to your team manually requires a great deal of time and effort.
Wouldn't it be great if you could automatically create tasks with different due dates and assign them to different people? A custom function can help you do just that. All you need to do is create a function that auto-creates multiple tasks and link it up with a workflow rule that triggers when a deal is closed.
Permissions and availability
- Users with the Manage Automation permission can create and update workflow rules.
- Users with the Manage Extensibility permission can write custom functions.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Create a workflow rule for the Deals module that triggers upon closing a deal. Learn more
- Write a custom Deluge function that creates multiple tasks and link it to the workflow rule. Learn more
- Test the workflow rule in a sandbox before deploying it in your production environment. Learn more
Create a workflow rule
- Navigate to Setup > Workflow Rules > +Create Rule.
- Select the Module as Deals from the drop-down list.
- Provide a name for the rule. For example: "Create tasks on deal closure".
- Add a description (optional), then click Next.
- In the Execute this workflow rule based on section, do the following:
- Choose Record Action, then select Edit from the drop-down.
- Check the box for Repeat this workflow whenever a Deal is edited.
- Choose Specific field(s) gets modified from the drop-down, then enter the condition "When <Stage> is modified to <any WON stages>".
Note: You can also enter a specific stage here. - Click Next.
- In the Which deals would you like to apply the rule to? section, select All Deals, 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 Deals - Deal Id, name it dealId, then click Save.
- Click Save & Execute Script.
- Click Save on the workflow rule page.
The code
dealDetails = zoho.crm.getRecordById("Deals",dealId.toLong());
//info dealDetails;
Ownerid = ifnull(dealDetails.get("Owner"),"").get("id");
Engineerid = 1234567890;
sublist = {"Survey Customer Site","Draw Cables and Clamp","Install Distribution Equipment","Set up Routers","Follow-up with Customer for Feedback"};
datelist = {"0","0","1","1","2"};
ownerlist = {Engineerid,Engineerid,Engineerid,Engineerid,Ownerid};
size = 5;
str = " ";
count = 0;
lst = leftpad(str,size).replaceall(" ","text,").trim().removeLastOccurence(",").toList();
for each item in lst
{
//create task
mp = Map();
mp.put("Subject",sublist.get(count));
duedate = today.toDate().addDay(datelist.get(count).toLong());
mp.put("Due_Date",duedate);
mp.put("Owner",ownerlist.get(count).toLong());
mp.put("Status","Not Started");
mp.put("Priority","Highest");
mp.put("What_Id",dealId);
mp.put("$se_module","Deals");
info mp;
createResp = zoho.crm.createRecord("Tasks",mp);
info createResp;
count = count + 1;
}
Notes
- Replace "1234567890" with the corresponding ID of the user in your CRM.
- With this code snippet, you can create up to five tasks. You can add or delete them according to your specific requirements.
- The due date for the first two tasks will be the trigger date; for the following two tasks, it will be trigger+1 day, and for the last task, it will be trigger+2 days.
- Enter a suitable subject, due date, status, and priority for creating the tasks.
- Use the accurate API names for their corresponding fields in the code snippet. Learn more
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Go to the Deals module and select the deal you wish to close.
- On the Deal Details page, update the stage to Closed Won or the appropriate stage.
The workflow rule will get triggered upon deal closure. - Check whether five new tasks were created with the proper due dates and owners.
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
- ModuleDeals
- 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