How to enable and disable a CRM 2011 Organization using C#/VB.Net and WCF Deployment Service or CRM 2011 SDK?
I want to be able to enable/disable a CRM 2011 Organization using Deployment Service (Deployment.Svc) or using CRM 2011 SDK (Microsoft.Xrm.Sdk.Deployment Namespace) using C# or VB.Net application.
I am using some code like this:
Dim StateReq As CRM2011DeploymentSvc.DeleteRequest
Dim StateResp As CRM2011DeploymentSvc.DeleteResponse
StateReq.EntityType = DeploymentEntityType.Organization
StateReq.InstanceTag.Id = FoundOrganization.OrganizationId
StateReq.InstanceTag.Name = FoundOrganization.UniqueName
StateResp = CType(_CrmDeployService.Ex开发者_StackOverflow社区ecute(StateReq), DeleteResponse)
1. Q1: This code is OK as far as deletion of entities(Organization, accounts etc) is concerned. but i am more interested in Enabling and disabling the organization (occasionally) along deleting (when required).
2. Q2: Lets say if i Delete an Organization, will i be able to undo delete or recover it. If yes then how and if not what else is the alternative? 3. Q3: In CRM 4.0 we can disable/Enable the organization using
**SetStateOrganizationRequest**
**SetStateOrganizationResponse**
Classes using the Deployment web service but in CRM 2011, the Deployment WCF Service does not contain any such method. What should i do to enable or disable the organization?
Replies are much appreciated.
Thank you.
ok i got the solution courtesy of ResultOnDemand
The following code worked for me
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);
精彩评论