Automation Series: Auto-update Task Closure Field Based on Due Date

Automation Series: Auto-update Task Closure Field Based on Due Date

In a project, tasks are owned and worked on by different users and each progresses at a different rate. With Zoho Projects, the task delay duration can be calculated automatically when a task runs past its due date. This gives project managers better visibility into delivery estimates without checking each task individually.

Consider an onboarding team working on tasks such as Contractor Enrolment, Implementation Timeline Discussion, and Lead Assignment, each aligned to a go-live schedule. As work moves forward, tasks are picked up and worked on by different members along the way. It gets tedious to calculate task delays individually as the project expands, making delivery reviews repetitive and time consuming.

 Whenever a task is marked as Completed, the workflow rule is triggered and the associated custom function compares the task Completion date against its Due date. Tasks that closed on or before the Due date are updated as On Time in the Closure field. Tasks that closed after the Due date are updated as Delayed and the number of overdue days is calculated and updated automatically. This helps project managers determine tasks that consistently take longer than planned, so future timelines can be adjusted before delays happen.

To configure this flow in your Zoho Projects portal,

      1. Navigate to the upper-right corner of the page and click   → Customization → Layouts and Fields → Tasks.
      2. Click the required layout and drag and drop to create the following Custom status and fields:
    1. Closure - Custom Picklist field with two values: On Time and Delayed.
    2. Days - Number field to capture the number of days delayed. This field will only populate when the closure status is Delayed.
    3. Stop - Checkbox field to prevent the Workflow Rule from repeatedly triggering after the task is updated.
    4. Re Open and Completed - Ensure the following statuses are available in your Task Layout. 


      3. Click Save.
      4. Navigate to   → Developer Space → Connections.
      5. Click Create Connection, choose Zoho Projects as the service, and add the following scopes:
    1. ZohoProjects.tasks.UPDATE
    2. ZohoProjects.portals.READ
    3. ZohoProjects.projects.READ


      6. Navigate to Custom Functions under Developer Space.
      7. Click the Tasks tab in the upper navigation panel.
      8. Create a new custom function and add the following 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.tasks.UPDATE, ZohoProjects.portals.READ, ZohoProjects.projects.READ
  2. projectsV3Endpoint = "https://projectsapi.zoho.in/api/v3/portal/";
  3. endPoint = "https://projects.zoho.in/restapi/portal/";
  4. format = "dd-MM-yyyy";
  5. statusName = "Completed";
  6. // Get task layout details
  7. taskLayoutDetailsResponse = invokeurl
  8. [
  9. url :endPoint + portalId + "/projects/" + projectId + "/tasklayouts"
  10. type :GET
  11. connection:"fieldupdateoncompletion"
  12. ];
  13. statusDetails = taskLayoutDetailsResponse.get("status_details");
  14. for each status in statusDetails
  15. {
  16. if(status.get("name").equalsIgnoreCase(statusName))
  17. {
  18. completedStatusId = status.get("id");
  19. }
  20. }
  21. params = Map();
  22. if(endDate != null)
  23. {
  24. days = daysBetween(toDate(zoho.currentdate.toString(format),format),toDate(toString(endDate,format)));
  25. if(days >= 0)
  26. {
  27. params.put("closure","On time");
  28. params.put("stop",true);
  29. updateTask = invokeurl
  30. [
  31. url :projectsV3Endpoint + portalId + "/projects/" + projectId + "/tasks/" + taskId
  32. type :PATCH
  33. parameters:params.toString()
  34. connection:"fieldupdateoncompletion"
  35. ];
  36. }
  37. if(days < 0)
  38. {
  39. delayedDays = days * -1;
  40. params.put("closure","Delayed");
  41. params.put("days",delayedDays);
  42. params.put("stop",true);
  43. updateTask = invokeurl
  44. [
  45. url :projectsV3Endpoint + portalId + "/projects/" + projectId + "/tasks/" + taskId
  46. type :PATCH
  47. parameters:params.toString()
  48. connection:"fieldupdateoncompletion"
  49. ];
  50. }
  51. }
  52. params.clear();
  53. params.put("status",{"id":completedStatusId});
  54. updateTask = invokeurl
  55. [
  56. url :projectsV3Endpoint + portalId + "/projects/" + projectId + "/tasks/" + taskId
  57. type :PATCH
  58. parameters:params.toString()
  59. connection:"fieldupdateoncompletion"
  60. ];
  61. return "success";
Info
  1. Lines 2 and 3: Replace the domain in the endpoint URLs to match your data centre.
  2. Line 5: Replace "Completed" with the custom task closure status configured in your portal.
  3. Lines 11, 34, 48 and 59: Replace "fieldupdateoncompletion" with your Zoho Projects connection name.
  4. Line 27: Replace "On time" with the Closure field value configured in your portal.
  5. Line 40: Replace "Delayed" with the Closure field value configured in your portal.
  6. Lines 24, 25, 37, 39, and 41: Replace "days" with the API name of your number field if it has been renamed.
      9. Add the following arguments during configuration.



      10. Click Save.
      11. Navigate to   → Automation → Workflow Rules.
      12. Click the Tasks tab in the upper navigation panel and click New Workflow Rule.
      13. Select Based on User Action as the execution condition and execute the rule when a task is Updated.
      14. Click Add Criteria+ and set the following criteria:
    1. Task Status Is Completed
    2. AND Stop Is Disabled
Notes
If you have configured a Custom Status or using the default Closed status, ensure the Task Status in the Workflow Rule criteria is set to match your portal configuration.
      15. Click +Add Action and select Update Field. Set Status to custom status Re Open.
      16. Click +Add Action again and select Associate Custom Function. Select the custom function created previously.



      17. Click Save Rule.
      18. Toggle the Workflow Rule Status on to enable it.



With this automation in place, teams can automatically track on-time and delayed tasks along with overdue days. This gives project managers better visibility into delivery timelines.

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

    Access your files securely from anywhere


          All-in-one knowledge management and training platform for your employees and customers.






                                Zoho Developer Community




                                                      • Desk Community Learning Series


                                                      • Digest


                                                      • Functions


                                                      • Meetups


                                                      • Kbase


                                                      • Resources


                                                      • Glossary


                                                      • Desk Marketplace


                                                      • MVP Corner


                                                      • Word of the Day


                                                      • Ask the Experts



                                                                • Sticky Posts

                                                                • Update on V2 API End-of-Life Timeline

                                                                  Dear Users, Earlier this year, we shared the launch of the V3 APIs and requested users to migrate from the older V2 APIs by December 2025. We have received valuable feedback from our users and partners regarding their migration timelines. We are happy
                                                                • Automation Series: Auto-assign Task Followers

                                                                  As task progresses, several users are required to stay aware of the updates to plan their upcoming work items efficiently. Manually adding users as followers for an active task might create additional overhead. With this automation, followers can be added
                                                                • WhatsApp Business Integration for Zoho Projects

                                                                  Delivery channel plays a decisive role in how quickly certain project updates translate into immediate actions. A release is ready to go live. An issue is marked critical. An approval is pending. These moments are less about tracking and more about timely
                                                                • Enhanced Collaboration and Global Web Tabs

                                                                  Hello Users, We are rolling out two key enhancements in Zoho Projects that will be part of our November release. Here’s what to expect: 1. Collaboration Section in the Left Navigation Panel What’s new? All communication and interactive tools will be grouped
                                                                • Choosing the Right Automation in Zoho Projects

                                                                  In any project, different types of actions are needed at different points. Some projects require control on how tasks move, some require reacting to updates, and some require executing additional actions beyond the task. Automation in Zoho Projects is


                                                                Manage your brands on social media



                                                                      Zoho TeamInbox Resources



                                                                          Zoho CRM Plus Resources

                                                                            Zoho Books Resources


                                                                              Zoho Subscriptions Resources

                                                                                Zoho Projects Resources


                                                                                  Zoho Sprints Resources


                                                                                    Qntrl Resources


                                                                                      Zoho Creator Resources



                                                                                          Zoho CRM Resources

                                                                                          • CRM Community Learning Series

                                                                                            CRM Community Learning Series


                                                                                          • Kaizen

                                                                                            Kaizen

                                                                                          • Functions

                                                                                            Functions

                                                                                          • Meetups

                                                                                            Meetups

                                                                                          • Kbase

                                                                                            Kbase

                                                                                          • Resources

                                                                                            Resources

                                                                                          • Digest

                                                                                            Digest

                                                                                          • CRM Marketplace

                                                                                            CRM Marketplace

                                                                                          • MVP Corner

                                                                                            MVP Corner









                                                                                              Design. Discuss. Deliver.

                                                                                              Create visually engaging stories with Zoho Show.

                                                                                              Get Started Now


                                                                                                Zoho Show Resources

                                                                                                  Zoho Writer

                                                                                                  Get Started. Write Away!

                                                                                                  Writer is a powerful online word processor, designed for collaborative work.

                                                                                                    Zoho CRM コンテンツ





                                                                                                      Nederlandse Hulpbronnen


                                                                                                          ご検討中の方