Thursday, December 30, 2010

Dynamics CRM 2011 SDK & sample code

SDK crm2011:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=420f0f05-c226-4194-b7e1-f23ceaa83b69

sample code
==========

Just a sample code for quick reference !

ClientCredentials credentials = new ClientCredentials();

credentials.Windows.ClientCredential = new System.Net.NetworkCredential(“admin”,“pwd “,“domain”);

Uri organizationUri = new Uri(“http://servername:port/orgname/XRMServices/2011/Organization.svc“);

Uri homeRealmUri = null;OrganizationServiceProxy orgService = new
OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
IOrganizationService _service = (IOrganizationService)orgService;
try{
Entity contact = new Entity(“contact”);

contact["lastname"] = “contact created using IOrganizationSerivce”;_service.Create(contact);

}
catch (Exception ex){
MessageBox.Show(ex.Message);

}
In case of early-bound, don’t forget to add the following line of code



OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
// This statement is required to enable early-bound type support.
_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());


Regards,
Imran

[MVP CRM] = https://mvp.support.microsoft.com/profile/imran.mustafa

MSN/IM= mscrmexpert@gmail.com
SKYPE= mscrmexpert
BLOG= http://microsoftcrm3.blogspot.com
Linkedin = http://www.linkedin.com/in/mscrmexpert
Twitter = @mscrmexpert