Search

AddMembers to a team

//The following code example demonstrates how to add a set of users to a team.
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the AddMembersTeamRequest object.
AddMembersTeamRequest addRequest = new AddMembersTeamRequest();

// Set the AddMembersTeamRequest TeamID property to the object ID of 
// an existing team.
addRequest.TeamId = new Guid("9AF74EF9-A04C-DA11-A0C5-000D9DD8CDAC");

// Set the AddMembersTeamRequest MemberIds property to an 
// array of GUIDs that contains the object IDs of one or more system users.
addRequest.MemberIds =  new Guid[] {new Guid("A0F2D8FE-6468-DA11-B748-000D9DD8CDAC")};

// Execute the request.
AddMembersTeamResponse addResponse = (AddMembersTeamResponse)service.Execute(addRequest);