Update Task API Limit Issue

Update Task API Limit Issue

I am running into issues with the API limit for update task in Zoho Projects. 

In a typical Project, we have 120-130 Tasks and I would like a field change made to the Project to propagate down to all Tasks that belong to the Project. (In this case "Territory). I am running the below function upon field change of Project.Territory to update Task.Territory.

Is there any reasonable way to get around the 100x API usage limit for this function?

  1. // Get all tasks for the specified project ID
  2. taskDetails = zoho.projects.getRecords(portalId,projectId,"tasks",0,0,"xxxxxxxxxx");
  3. tasksList = taskDetails.get("tasks");
  4. // Create a map to specify the custom field update
  5. customFieldsMap = Map();
  6. customFieldsMap.put("UDF_CHAR82",territory);
  7. // Create the main map and nest the custom fields map within "custom_fields"
  8. updateTaskParameter = Map();
  9. updateTaskParameter.put("custom_fields",customFieldsMap);
  10. //only run code if Project.Territory is not null
  11. if(territory != null)
  12. {
  13. // Loop through each task in taskDetails (Tasks belonging to projectId)
  14. for each  task in tasksList
  15. {
  16. // Access the ID of each task and Territory (UDF_CHAR82) 
  17. taskId = task.get("id");
  18. taskTerr = task.get("UDF_CHAR82");
  19. //Check if Task has subtasks
  20. taskisParent = task.get("isparent");
  21. // If Task has Subtasks get all Subtasks belonging to this Task
  22. if(taskisParent == TRUE)
  23. {
  24. subTaskResponse = invokeurl
  25. [
  26. url :projectsAPIEndPoint + "/portal/" + portalId + "/projects/" + projectId + "/tasks/" + taskId + "/subtasks/"
  27. type :GET
  28. connection:"xxxxxxxxxx"
  29. ];
  30. //For each Subtask belonging to this task update Territory if not already matching
  31. for each  subTask in subTaskResponse.get("tasks")
  32. {
  33. // Access the ID of each task and Territory (UDF_CHAR82) 
  34. subtaskId = subTask.get("id");
  35. subtaskTerr = subTask.get("UDF_CHAR82");
  36. if(subtaskTerr.toString() != territory.toString())
  37. {
  38. subtaskUpdate = zoho.projects.update(portalId,projectId,"Tasks",subtaskId,updateTaskParameter,"xxxxxxxxxx");
  39. }
  40. }
  41. }
  42. // Perform the update operation if Task.Territory differs from Project.Territory
  43. if(taskTerr.toString() != territory.toString())
  44. {
  45. taskUpdate = zoho.projects.update(portalId,projectId,"Tasks",taskId,updateTaskParameter,"xxxxxxxxxx");
  46. }
  47. }
  48. }
  49. return taskUpdate;