It's common for sales teams to create tasks to track outreach activities against lead records. Sales reps typically close these tasks once completed. However, when using blueprints to manage process transitions—such as moving from a "Set up call appointment" state to a "Call completed" state—those associated tasks become redundant.
Manually closing these tasks adds unnecessary administrative overhead and consumes valuable time. If left open, they clutter task queues, create false urgency for reps, and distort pipeline activity reports. In situations like this, you can use our low-code tools to mark tasks as completed automatically.
All you need to do is write a custom function and connect it to the "After" transition in your blueprint rule so that it automatically closes specific state-associated tasks once the transition is completed. By doing so, you can maintain a clean task pipeline, accurate reporting, and zero manual overhead for your team. Read on to learn more.
Permissions and availability
- Users with the Manage Automation permission can create and update Blueprints.
- Users with the Manage Extensibility permission can create custom functions.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Create a blueprint for the Leads module with at least two states—"Set up call appointment" and "Call completed"—connected by a transition. Learn more
- Write a custom Deluge function that fetches the task with a specific subject and updates its status to "Completed". Learn more
- Test the blueprint in a sandbox before deploying it to your production environment. Learn more
Create a blueprint
- Navigate to Setup > Blueprint > + Create Blueprint.
- Enter a name for the blueprint. For example: "Lead Outreach Process".
- Select the Leads module from the dropdown list.
- Choose the layout and field (e.g., Lead Status) for the process.
- Add a description, if required, then click Next.
- In the Blueprint Editor, drag and drop the required states (e.g., Set up call appointment and Call completed) and connect them.
- Create a transition between the states by clicking the + icon between them (e.g., "Complete Call").
Note: You must have already created a transition (e.g., "Schedule Appointment") before this that creates a task as an Associated Item, with the subject "Set up call appointment". - Open the "Complete Call" transition, navigate to the After tab, and click + Custom Actions.
- Select New Function and then select Write your own.
- Provide a name for the function, as well as a description, if necessary.
- In the Deluge Script Editor, do the following:
- Copy and paste the code provided below.
- Click Edit Arguments.
- Choose Leads - Lead Id, name it "leadId", and click Save.
- Click Save & Execute Script.
- Click Publish on the blueprint page.
The code
// Get all tasks related to the Lead record
leadRelatedTasks = zoho.crm.getRelatedRecords("Tasks","Leads",leadId);
for each rec in leadRelatedTasks
{
// Get task details
tSubj = rec.get("Subject");
tStatus = rec.get("Status");
// Check if task subject contains the search pattern and is not already completed
if(tSubj.contains("Set up call appointment") && tStatus != "Completed")
{
//Close the task when matched
info "Need to close task ID";
tMap = Map();
tMap.put("Status","Completed");
tResp = zoho.crm.updateRecord("Tasks",rec.get("id"),tMap);
info tResp;
}
}Notes
- Use the accurate API name of the fields used in the code snippet (e.g., "Subject"). Learn more
- Replace "Set up call appointment" with the specific task subject used in your organization.
- The code above is an example of automatically closing tasks that are created during a Blueprint process when a transition completes. You can use this code for any other module, such as Leads and Deals, by modifying the module name and other parameters.
Tip
- Configure and test the solution in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Navigate to the Leads module and open a lead record.
- Click the Schedule Appointment transition button on the Blueprint strip.
- In the transition form, create a task with the subject "Set up call appointment", specify a due date, and complete any other mandatory fields.
- Click Save.
- Check the following:
- The lead has moved to the Set up call appointment state.
- The new task appears in the lead's related Tasks list.
- Click the Complete Call transition button on the Blueprint strip.
- Check the following:
- The lead has moved to the Call completed state.
- The task with the subject Set up call appointment is now marked as "Completed".
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
- ModuleTasks
- Trigger PointBlueprint
- 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