Remove user from Access Team in CRM 2013 and 2015


Here is the C# code to remove the user from the access team.

RemoveUserFromRecordTeamRequest objRemoveUser = new RemoveUserFromRecordTeamRequest();

objRemoveUser.Record = entRecord;
objRemoveUser.SystemUserId = guidSystemUserId;
objRemoveUser.TeamTemplateId = guidTeamTeplateId;
RemoveUserFromRecordTeamResponse response = RemoveUserFromRecordTeamResponse)service.Execute(objRemoveUser);

Record — Entity Reference object of the record
SystemUserId — User which you want to remove
TeamTeamplateId — Access Team Template Guid

Here is the code to get the template guid from template name.

public Guid GetTemplateIDByName(IOrganizationService objService, string strTemplateName)

      Guid guidTeamTeplateId = new Guid();
      //  Query using ConditionExpression and FilterExpression
      ConditionExpression condition = new ConditionExpression();
      //attribute name add to condition
      condition.AttributeName = “teamtemplatename”;
      //operator add to condition
      condition.Operator = ConditionOperator.Equal;
      //values added to condition
      // filter creation
      FilterExpression filter = new FilterExpression();
      //condition added
      //create query expression
      QueryExpression query = new QueryExpression(“teamtemplate”);
      //filter added to query
      //retrieve all columns
      query.ColumnSet = new ColumnSet(“teamtemplatename”);
      // execute query which will retrieve the Access team teamplate
      EntityCollection accessTeamColl = objService.RetrieveMultiple(query);
      if (accessTeamColl != null && accessTeamColl.Entities.Count > 0)
          guidTeamTeplateId = accessTeamColl.Entities[0].Id;
      return guidTeamTeplateId;

Add user from Access Team CRM 2013 and 2015

Happy CRM’ing


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s