Automation Series: Assign Subsequent Task Owner on Completion

Automation Series: Assign Subsequent Task Owner on Completion

When a project progresses, tasks get piled up over time. As new tasks are created, tracking ownership and assigning them can become time consuming. In Zoho Projects, this can be addressed by automating task assignment using Custom Function, so that ownership is assigned once the previous task is Closed.

Use-case

In a pharmaceutical manufacturing unit, the procurement phase involves a set of tasks such as raw material sourcing, quality checks, approvals etc. These tasks are often repetitive and handled within the task list. Even if tasks are added by different teams based on requirements, and the list continues to expand, task ownership might remain unassigned until a user is assigned manually. This delays the other upcoming tasks and project timelines.

With this automation, a workflow rule is triggered when a task is marked as Closed. When a Custom Function is associated with the rule, it automatically assigns the next task to a particular user. This ensures related tasks continue with the same owner without manual intervention.

To configure this flow in your Zoho Projects portal,

      1. Navigate to the upper-right corner of the page.
      2. Click  → Developer Space → Connections.
      3. Click Create Connection and add the following scopes:
  1. ZohoProjects.users.READ
  2. ZohoProjects.tasks.READ
  3. ZohoProjects.tasks.UPDATE



      4. Navigate to Custom Functions under Developer Space.
      5. Click on the Tasks tab in the upper navigation panel.
      6. Create a new custom function and add the below Deluge script.
Notes
Ensure that the portal URL aligns with your data centre. If not, the function may not execute as expected.
  1. // scopes: ZohoProjects.users.READ, ZohoProjects.tasks.READ, ZohoProjects.tasks.UPDATE
  2. // replace userEmail - ["alex@abc.com","bob@abc.com"] with your next task owner email id
  3. userEmail = ["alex@abc.com","bob@abc.com"];
  4. projectsV3Endpoint = "https://projectsapi.zoho.com/api/v3/portal/";
  5. params = Map();
  6. params.put("filter",{"criteria":{{"field_name":"status","criteria_condition":"custom_condition","value":{"${ALL_OPEN}"}}},"pattern":"1"});
  7. params.put("sort_by","ASC(created_time)");
  8. getTasks = invokeurl
  9. [
  10. url :projectsV3Endpoint + portalId + "/projects/" + projectId + "/tasks"
  11. type :GET
  12. parameters:params
  13. connection:"connectionprojects"
  14. ];
  15. nextTaskId = getTasks.get("tasks").get(0).get("id");
  16. owners = List();
  17. for each email in userEmail {
  18. userEmails = List();
  19. userEmails.add(email);
  20. params = Map();
  21. params.put("type",1);
  22. params.put("page",1);
  23. params.put("view_type",1);
  24. params.put("per_page",50);
  25. params.put("filter",{"criteria":{{"cfid":"4","criteria_condition":"contains","value":userEmails}},"pattern":"1"});
  26. getAllUsers = invokeurl
  27. [
  28. url :projectsV3Endpoint + portalId + "/projects/" + projectId + "/users"
  29. type :GET
  30. parameters:params
  31. connection:"connectionprojects"
  32. ];
  33. userId = getAllUsers.get("users").get(0).get("id");
  34. zpuids = Map();
  35. zpuids.put("zpuid",userId);
  36. owners.add(zpuids);
  37. }
  38. updateTaskParameter = Map();
  39. updateTaskParameter.put("owners_and_work",{"owners":owners});
  40. updateTaskResponse = invokeurl
  41. [
  42. url :projectsV3Endpoint + portalId + "/projects/" + projectId + "/tasks/" + nextTaskId
  43. type :PATCH
  44. parameters:updateTaskParameter.toString()
  45. connection:"connectionprojects"
  46. ];
  47. return "success";
Info
Line 3: Add the user email IDs to whom the tasks should be assigned.
Line 4: Modify the data centre URL to match your Zoho Projects portal.
Lines 13, 31 and 45: Replace "connectionprojects" with your Zoho Projects connection name.
      7. Add the following arguments during configuration.



      8. Navigate to   → Automation → Workflow Rules.
      9. In the upper navigation panel click on Tasks Tab → New Workflow Rule.
      10. Select the execution condition as Based on User Action and execute the rule when a task is Updated.
      12. Click Add Criteria+ and set this trigger Task Status Is Closed from the drop-down
      11. Click +Add Action and select Associate Custom Function and select the previously created custom function.
      12. Click Save Rule.
      13. Toggle the Workflow Rule Status on to enable it.



With this automation in place, ownership assignment becomes effortless, ensuring tasks are taken up as ongoing ones are complete.

If you have any questions, feel free to drop a comment below or reach out to us at support@zohoprojects.com.