Power of Automation:: Streamline Associated Teams based on the Task Owner update.

Power of Automation:: Streamline Associated Teams based on the Task Owner update.

Hello Everyone,
 
A Custom function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it.
 
Requirement:

One of our customers wanted to update the Associated Team automatically based on the Task owner added.

For example, If User Alex is associated with both the Networking and Central IT Teams, making Alex as Task Owner will automatically update the Task with his Associated Teams. Similarly, when another user is added, their associated Teams will also be updated to the Tasks provided those Teams are part of the Project. 

This can be implemented using
Task custom functions along with Workflow rules.

Custom function code:
 
zuidList = list();
/*          Get all owners and teams.      */
for each  owner in taskOwners
{
zuidList.add(owner.get("id").toString());
}
getTeamUsers = invokeurl
[
url :endPointV3 + portalId + "/teams/users"
type :GET
connection:"*XXXXX*"
];
if(getTeamUsers.get("page_info").get("count") > 0)
{
associtedTeams = list();
for each  user in getTeamUsers.get("team_users")
{
info zuidList + " == " + user.get("zuid") + " : " + zuidList.contains(user.get("zuid"));
if(zuidList.contains(user.get("zuid")))
{
associtedTeams.addAll(user.get("associted_teams"));
}
}
associtedTeams = associtedTeams.distinct();
}
/*   Get all associate teams      */
getAssociatedTeams = invokeurl
[
url :endPointV3 + portalId + "/projects/" + projectId + "/teams"
type :GET
connection:"*XXXXX*"
];
// info getAssociatedTeams;
 
associteTeam = list();
for each  teamid in associtedTeams
{
associteTeam.add({"id":teamid});
}
/*   Remove teams that are already associated   */
if(getAssociatedTeams.get("page_info").get("count") > 0)
{
for each  team in getAssociatedTeams.get("teams")
{
if(associtedTeams.contains(team.get("id")))
{
associtedTeams.removeElement(team.get("id"));
}
}
}
// info associtedTeams;
/*   Associate teams to project of not added   */
if(associtedTeams.size() > 0)
{
params = Map();
params.put("team_ids",associtedTeams);
info params;
associateTeamToProject = invokeurl
[
url :endPointV3 + portalId + "/projects/" + projectId + "/associate-teams"
type :POST
parameters:params
connection:"*XXXXX*"
];
info associateTeamToProject;
}
/*   Associate teams to task of not added   */
if(associteTeam.size() > 0)
{
params = Map();
params.put("teams",{{"add":associteTeam}});
info params;
associateTeamToTask = invokeurl
[
url :endPointV3 + portalId + "/projects/" + projectId + "/tasks/" + taskId
type :PATCH
parameters:params.toString()
connection:"*XXXXX*"
];
info associateTeamToTask;
}
return "success";
 
Make sure to replace XXXXX with Zoho Projects connection link name along with scopes ZohoProjects.tasks.UPDATE, ZohoProjects.teams.ALL. Please find the screenshot of the list of parameters to be mapped for reference.
 
We hope you found this post useful. If you have any questions, feel free to share them in the comments below.


      • Sticky Posts

      • Schedule Exports for Regular Project Updates

        Tracking project data often means exporting data at regular intervals. Instead of manually exporting data every time, users can schedule exports for Phases, Tasks, and Tasks in Zoho Projects. These exports can be set to run once, daily, weekly, or monthly
      • Set Custom Business Calendars and Holidays for Global Teams

        Managing a project across diverse teams means accounting for more than just tasks and deadlines; it means acknowledging how and when each team actually works. Users might follow different working days or observe region-specific holidays that cannot be
      • Introducing Version-3 APIs - Explore New APIs & Enhancements

        Happy to announce the release of Version 3 (V3) APIs with an easy to use interface, new APIs, and more examples to help you understand and access the APIs better. V3 APIs can be accessed through our new link, where you can explore our complete documentation,
      • Restore Trashed Records Anytime Within 30 Days

        Access the recycle bin from the Data Administration tab under the settings page in Zoho Projects, which gives better control over the trashed data. When records like projects, phases, task lists, tasks, issues, or project templates are trashed, they are
      • Organize and Clone Task Custom Views

        We have rolled out two new enhancements to task custom views: Custom View Groups and Custom View Clone. Custom View Groups Similar to predefined view groups, we have introduced groups for custom views to help organize and categorize them. My Custom Views: