31. March 2011 15:02
With the c# code below you can disable or enable an organisation in Microsoft CRM 2011 by using the Deployment Service:
EntityInstanceId i = new EntityInstanceId();
i.Id = OrganisationId; //Organisation Id
DeploymentService.Organization organization = (DeploymentService.Organization)Provider.deploymentservice.Retrieve(DeploymentEntityType.Organization, i);
//Update status to disabled
organization.State = OrganizationState.Disabled;
DeploymentService.UpdateRequest updateRequest = new UpdateRequest();
updateRequest.Entity = organization;
//update status
Provider.deploymentservice.Execute(updateRequest);