Sunday 29 June 2014

CRM 2011/ 2013 Add Security Role to Team Programmatically C#

To assign security to a Team in CRM 2011 or CRM 2013, you can use this code:

public void AddSecurityRoletoTeam(IOrganizationService service, Guid securityRoleId, Guid teamId)
{
     service.Associate(Team.EntityLogicalName,
     teamId,
     new Relationship("teamroles_association"),
     new EntityReferenceCollection() { new EntityReference(Role.EntityLogicalName, securityRoleId) });
 }

*Both Team and Security Role should be in the same Business Unit

Hope it helps!

2 comments:

My Name is..