Automation Series: Schedule Function for repetitive tasks

Automation Series: Schedule Function for repetitive tasks

Many organizations that run multiple projects need the same activities happening at regular intervals. Activities may range between monthly maintenance, calibration, upkeep, or compliance checks. In this article, we shall discuss how to automate the process efficiently.

Let's consider a facilities management firm managing multiple holiday homes, each set up as a separate project in the portal. Deep cleaning is a recurring activity that needs to be completed across every property on the 30th of every month. Let's see how to automate this with Schedule Function.

Unlike custom functions, which are triggered by project-specific events such as task creation, field updates, project updates, or user actions, a Schedule Function runs automatically at a predefined date and time at the portal level. In this scenario, it creates the deep-cleaning task simultaneously across all active projects every month, eliminating the need for manual initiation.

Let's quickly walk through the setup,

      1. Navigate to the upper-right corner of the page and click  → Developer Space → Connections.
      2. Click Create Connection, choose Zoho Projects as the service, and add the following scope:
  1. ZohoProjects.tasks.CREATE
  2. ZohoProjects.projects.READ

Connection

      3. Navigate to Developer Space → Schedule Functions.
      4. Click Create Schedule Function in the upper-right corner.
      5. Enter a Function Name and Description.
      6. Set the arguments as follows:

Arguments

      7. Set the Schedule Date and Time for the first execution.
      8. Set the Repeat Type as Monthly and configure the remaining schedule settings based on your preference.
      9. Add the following Deluge script in the script editor. The script retrieves active projects under a portal and creates the task scheduled for the 30th of every month.
  1. projectData = Map();
  2. projectData.put("status","active");
  3. projectdetails = invokeurl
  4. [
  5. url :"https://projectsapi.zoho.com/restapi/portal/" + portalId + "/projects/"
  6. type :GET
  7. parameters:projectData
  8. connection:"projects"
  9. ];
  10. projects = projectdetails.get("projects");
  11. for each project in projects
  12. {
  13. projectId = project.get("id");
  14. data = Map();
  15. data.put("name","Task name here");
  16. data.put("description","Enter your description here");
  17. data.put("start_date",toString(zoho.currentdate,"MM-dd-YYYY"));
  18. createTaskResponse = zoho.projects.create(portalId,projectId,"tasks",data,"projects");
  19. info createTaskResponse;
  20. }
Info
  1. Line 5: Replace the domain like AU, EU, CN, IN etc.in the URL to match your data centre.
  2. Line 15 and 16: Replace your task name and description to be created across all projects.
  3. Lines 8 and 18: Replace "projects" with your Zoho Projects connection name.
      10. Click Schedule to save and trigger the function. The required task is now created across all the projects.

Task Creatio


Task Details Page

When handling repetitive actions within a single project, you can set up a Recurring task. But the Schedule Function extends this capability at the portal level, creating the same task across every project simultaneously. The schedule can be customised to run daily, weekly, monthly, or on a custom schedule, making it ideal for safety briefings, compliance audits, invoicing, and maintenance tasks across your portal.

Do give this a try and let us know how it works for you in the comments below, or write to us at support@zohoprojects.com for any questions.