private void ReplaceMemberOnAllTeam() { IOwner selectedMember = null; string selectedMemberId = string.Empty; IOwner replaceMember = null; string replaceMemberId = string.Empty; if (lueSelectedMember.LookupResultValue != null) { selectedMemberId = lueSelectedMember.LookupResultValue.ToString(); selectedMember = Sage.Platform.EntityFactory.GetById <IOwner>(selectedMemberId); } if (lueReplaceMember.LookupResultValue != null) { replaceMemberId = lueReplaceMember.LookupResultValue.ToString(); replaceMember = Sage.Platform.EntityFactory.GetById <IOwner>(replaceMemberId); } if ((selectedMember != null) && (replaceMember != null)) { IList <ITeam> teams = Sage.SalesLogix.Team.Rules.GetTeams(); foreach (ITeam team in teams) { if (team.ContainsMember(selectedMember)) { IOwnerJoin member = Sage.Platform.EntityFactory.GetByCompositeId(typeof(IOwnerJoin), new[] { "ParentOwnerId", "ChildOwnerId" }, new[] { team.Id, selectedMember.Id }) as IOwnerJoin; team.RemoveMember(member); // keep the security profile from the original member team.AddMemberWithSecurityProfile(replaceMember, member.OwnerSecurityProfile); } } RedirectTo(replaceMember); } }
public void RemoveDepartmentFromAllTeams(IList <string> targetIds) { IList <ITeam> teams = Sage.SalesLogix.Team.Rules.GetTeams(); foreach (ITeam team in teams) { foreach (string selectedDepartId in targetIds) { IOwnerJoin selectedDepart = EntityFactory.GetByCompositeId(typeof(IOwnerJoin), new string[] { "ParentOwnerId", "ChildOwnerId" }, new object[] { team.Id, selectedDepartId }) as IOwnerJoin; if (selectedDepart != null) { team.RemoveMember(selectedDepart); } } } }