Tuesday, December 9, 2008

Using New CrmDeploymentService CRM 4.0.


We have a new webservice in CRM 4.0 i.e. CrmDeploymentService
This is the end-point for this web service
http:///mscrmservices/2007/crmdeploymentservice.asmx

Using CrmDeploymentService we can do the following:
Create/Delete/Disable/Enable/Update/Set Default an organization etc.

There are two types of Microsoft Dynamics CRM deployment entities: Organization and Server. The Deployment SDK provides programmatic access for manipulating the Organization entity. It does not currently enable you to write code against the Server entity for actions such as enabling and disabling a Microsoft Dynamics CRM server.

We have a separate sdk for the Deployement. We can download the sdk at the following location
http://www.microsoft.com/downloads/details.aspx?FamilyId=2874D878-E28D-4530-A185-4DEE1FCDD12E&displaylang=en

When working with the Deployment SDK, you should be familiar with software development practices in general and Microsoft Visual C# or Microsoft Visual Basic coding practices in particular. In addition, you should be familiar with using Web services and have access to a suitable development environment.

When using the Deployment SDK, it is helpful to have the Microsoft Dynamics CRM 4.0 Software Development Kit (SDK) available as a reference.

The Microsoft Dynamics CRM 4.0 SDK is the primary development resource for Microsoft Dynamics CRM 4.0 and is a guide for developers writing server-side code, custom business logic, plug-ins, integration modules, custom workflow modules, and more. The SDK provides an architectural overview of Microsoft Dynamics CRM, the entity model, security model, Web services, and sample code.



Some basic examples of using the service

// Create an instance of CrmDeploymentService
CrmDeploymentService myDeployService = new CrmDeploymentService(); 
myDeployService.Credentials = System.Net.CredentialCache.DefaultCredentials; 
myDeployService.Url = ” valid url”;
 
// To retrieve server license type information 
RetrieveLicenseRequest myLicRequest = new RetrieveLicenseRequest();
RetrieveLicenseResponse myLicResponse = (RetrieveLicenseResponse)myDeployService.Execute(myLicRequest);
MessageBox.Show(“License Type “ + myLicResponse.LicenseType.ToString());

 
// To get the organization information
RetrieveAllRequest myRetriveAllRequest = new RetrieveAllRequest();
 
// only organization is supported ( other is Server)
myRetriveAllRequest.EntityName = EntityName.Organization;
RetrieveAllResponse myRetriveAllResponse = (RetrieveAllResponse)myDeployService.Execute(myRetriveAllRequest);
 
foreach(DeploymentEntity myEntity in myRetriveAllResponse.Entities)
{
Organization myOrganization = (Organization)myEntity;
MessageBox.Show(myOrganization.FriendlyName);
MessageBox.Show(myOrganization.Id.ToString()); 
MessageBox.Show(myOrganization.UniqueName);
}

//// To disable an organization
SetStateOrganizationRequest myOrgSetStateRequest = new SetStateOrganizationRequest();
myOrgSetStateRequest.EntityName = EntityName.Organization;
myOrgSetStateRequest.Id = new Guid(“4c7fc991-0a41-dd11-bfd9-001d7d22e1af”);
myOrgSetStateRequest.State = OrganizationState.Disabled;
SetStateOrganizationResponse myOrgSetStateResponse =(SetStateOrganizationResponse) myDeployService.Execute(myOrgSetStateRequest);
 

No comments: