Introduction
Start your Dynamics CRM operations from your ASP.NET application. In this article we will learn and look how to connect Dynamics CRM.
We need to download CRM SDK to connect CRM.
For more information you can refer to this
link.
About SDK and Useful Libraries information
- using microsoft.crm.sdk.proxy.dll;
-
- using microsoft.xrm.sdk.dll;
-
- using microsoft.xrm.client.dll;
Conceptual Information
CRM SDK provides required essentials to make proper connection,
Define Data Connection
In this section, learn how to define Dynamics CRM Connection,
- OrganizationService service = new OrganizationService("YourCRMConnectionString");
Organization service is the data connection class,
- String YourCRMConnectionString = @"Url=http://Servername/yourworkCatalog; Domain=mydomain; Username=*******; Password=*****;"
Other values,
- service.Server = "Servername";
- service.user = "username";
- service.organization = "*****";
Simple format otherwise,
- <connectionStrings>
- <add name="Server=servername, organization=YourCatalogworks, user=****" connectionString="Url=http://myserver/AdventureWorksCycle; Domain=SalesLabs; Username=maruthi; Password=********;" />
- </ connectionStrings>
Get Sample Record
The following business logic helps you to get Sample Account Records,
- public List < SampleAccountEntryRecords > GetRecords()
- {
- using(OrganizationService service = new OrganizationService("YourCRMConnectionString"))
- {
- QueryExpression query = new QueryExpression
- {
- EntityName = "account",
- ColumnSet = new ColumnSet("accountid", "name", "revenue", "numberofemployees", "primarycontactid")
- };
- List < SampleAccountEntryRecords > info = new List < SampleAccountEntryRecords > ();
- EntityCollection accountRecord = service.RetrieveMultiple(query);
- }
- }
Sample Data Model
- public class SampleAccountEntryRecords
- {
- public Guid AccountID
- {
- get;
- set;
- }
- public string AccountName
- {
- get;
- set;
- }
- public int NumberOfEmployees
- {
- get;
- set;
- }
- public Money Revenue
- {
- get;
- set;
- }
- public EntityReference PrimaryContact
- {
- get;
- set;
- }
- public string PrimaryContactName
- {
- get;
- set;
- }
- public decimal RevenueValue
- {
- get;
- set;
- }
- }
The above snippets help us to get records from CRM.
References: For more information refer the
link,