Hi Community.
I am setting up a method to assign a user to multiple teams based on a form. The issue I am having is that it seems to only apply the user to the first team I select (using a multi-value list). Essentially, I am defining on the form -
The user identity to add
The name of the team to add them to
Their team role and regions they are responsible for
Code is below:
Innovator inn = this.getInnovator(); //Get the form used to make the GPR change selections Item qryGprItem = this.newItem(this.getAttribute("type"), "a_GetControlledItem"); qryGprItem.setID(this.getID()); Item gprItem = qryGprItem.apply(); string[] prodCats = gprItem.getProperty("a_add_to_prodcat").Split(','); string regions = gprItem.getProperty("a_add_to_region"); string gprAction = gprItem.getProperty("a_add_or_remove"); foreach (string prodCatValue in prodCats) { string prodCat = prodCatValue; Item qryTeamItem = inn.newItem("Team", "get"); qryTeamItem.setProperty("name", prodCat); Item teamItem = qryTeamItem.apply(); if (gprAction == "Add") { Item teamMember = inn.newItem("Team Identity", "add"); teamMember.setPropertyItem("source_id", teamItem); teamMember.setPropertyItem("related_id", gprItem.getPropertyItem("a_user_to_modify")); teamMember.setProperty("a_team_region", regions); teamMember.setPropertyItem("team_role", gprItem.getPropertyItem("a_gpr_role")); return teamMember.apply(); } if (gprAction == "Remove") { } } return this;