In this article I am going to describe how to connect asp. net MVC application from Microsoft dynamics 365 and perform operation on Microsoft dynamics 365 entity. So here I am going to describe step by step all thing first of all I am going to create trail account on Microsoft dynamics 365 for learning purpose it provides one-month trial for learn dynamics CRM.
Some basic concept about Microsoft dynamics 365.
What is Microsoft dynamics CRM
It is a software package of customer relationship management system developed by Microsoft. It’s enhancing the customer relationship of any organization in sales, marketing and customer service sectors. It manages the company’s interaction with current and futures customers. This can help to reduce the cost and increase profitability of organization and increase the customer’s satisfactions and loyalty.
Microsoft dynamics CRM is two types.
CRM Online
It is cloud based CRM everything managed by Microsoft itself e.g. ( Backend process, server setup, deployment, database and licensing ) on their own Microsoft server. It works on subscription based.
CRM on-premise
It is more customizable and more robust package of CRM you can deploy application and database in your own server. It’s allowed more control over everything e.g. Customization, setup, deployment, backup and licensing.
Note: Microsoft dynamic CRM 2016 is the latest version. So I am going to create one month free trial account of this version for learning purpose.
Navigate the URL : https://trials.dynamics.com
Step 1 Click on “Sign up here” button on top right corner then a popup will open.
Step 2
Fill all the required information on this form and then click next button after that a next popup will open.
Step 3
Fill you User-id and password details and click on next button.
Step 4
Now you will get OTP. Please verify this and click on setup.
Step 5Now select language, currency then click on complete setup. It takes some times in complete the setup.
Note: Once setup is complete you can login by using userid and password which you have setup in step 3 at URL https://login.microsoftonline.com and do the following steps.
Step 6
Now find the Microsoft dynamics 365 Endpoint for connect the Asp .net MVC application.
Step 7
Now need to download Microsoft dynamics 365 SDK which help us connect the application with Microsoft dynamics 365.
Step 8
Now our SDK is downloaded we need to extract this SDK into your local system for that i have created a separate folder name "Microsoft dynamics 365 SDK extract".
Step 9
Now we need to create a project in visual studio. So please New=>Project =>(MVCDynamicCRM).
Step 10
Now create a folder "Lib" in your project and copy and paste two .dll file from the folder "Microsoft dynamics 365 SDK extract" into "Lib" folder and add reference in your project from Lib folder and also add reference of ServiceModel.
Step 11
Now all the configuration things are ready, we need to write the code in C# for connect the Microsoft dynamics 365. So I have create a method
Note : Above written CreateService() method connects from Microsoft dynamic and return IOrganizationService which will be use for perform operation on CRM entity.
Now everything is done press F5 for run the application and see the output.
Note : In my next article I will describe how to create custom entity over Microsoft dynamics 365 and perform CRUD operation on that entity.
Some basic concept about Microsoft dynamics 365.
What is Microsoft dynamics CRM
It is a software package of customer relationship management system developed by Microsoft. It’s enhancing the customer relationship of any organization in sales, marketing and customer service sectors. It manages the company’s interaction with current and futures customers. This can help to reduce the cost and increase profitability of organization and increase the customer’s satisfactions and loyalty.
Microsoft dynamics CRM is two types.
CRM Online
It is cloud based CRM everything managed by Microsoft itself e.g. ( Backend process, server setup, deployment, database and licensing ) on their own Microsoft server. It works on subscription based.
CRM on-premise
It is more customizable and more robust package of CRM you can deploy application and database in your own server. It’s allowed more control over everything e.g. Customization, setup, deployment, backup and licensing.
CRM Online | CRM On-Premise |
This is cloud based solution. It’s server and databases are managed by Microsoft. | It is customizable and manageable solution server and database are managed by customer. |
You can easily setup within few hours by subscription( number of user’s and space) | It take more time in setup and also need technical skill. |
It supports less customization. | It supports more customization. |
It does not give option to perform manual data backup and restore options. Because database is hosted on Microsoft server to it take backup on daily based itself. | It provide complete control to manage your database. |
It works on your subscription plan number of user’s and data storage space 5GB. | It does not have such types of limitation because data exists on your server. |
It automatic supports updates of future version. | Need to install updates by administrator. |
Note: Microsoft dynamic CRM 2016 is the latest version. So I am going to create one month free trial account of this version for learning purpose.
Navigate the URL : https://trials.dynamics.com
Step 1 Click on “Sign up here” button on top right corner then a popup will open.
Step 2
Fill all the required information on this form and then click next button after that a next popup will open.
Step 3
Fill you User-id and password details and click on next button.
Step 4
Now you will get OTP. Please verify this and click on setup.

Step 6
Now find the Microsoft dynamics 365 Endpoint for connect the Asp .net MVC application.
Step 7
Now need to download Microsoft dynamics 365 SDK which help us connect the application with Microsoft dynamics 365.
Step 8
Now our SDK is downloaded we need to extract this SDK into your local system for that i have created a separate folder name "Microsoft dynamics 365 SDK extract".
Now we need to create a project in visual studio. So please New=>Project =>(MVCDynamicCRM).
Step 10
Now create a folder "Lib" in your project and copy and paste two .dll file from the folder "Microsoft dynamics 365 SDK extract" into "Lib" folder and add reference in your project from Lib folder and also add reference of ServiceModel.
Step 11
Now all the configuration things are ready, we need to write the code in C# for connect the Microsoft dynamics 365. So I have create a method
using System.ServiceModel;
using Microsoft.Xrm.Sdk;
private Microsoft.Xrm.Sdk.IOrganizationService CreateService()
{
Microsoft.Xrm.Sdk.IOrganizationService _service = null;
System.ServiceModel.Description.ClientCredentials credential = new System.ServiceModel.Description.ClientCredentials();
System.ServiceModel.Description.ClientCredentials devicecredential = new System.ServiceModel.Description.ClientCredentials();
credential.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
string organizationserviceendpoint = "Your CRM Endpoint URL";
string crmusername = "Your CRM Username ";
string crmpassword = "Your CRM Password";
Uri organizationurl = new Uri(organizationserviceendpoint);
Uri homerealuri = null;
using (Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy serviceproxy = new Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy(organizationurl, homerealuri, credential, devicecredential))
{
serviceproxy.ClientCredentials.UserName.UserName = crmusername;
serviceproxy.ClientCredentials.UserName.Password = crmpassword;
serviceproxy.ServiceConfiguration.CurrentServiceEndpoint.EndpointBehaviors.Add(new Microsoft.Xrm.Sdk.Client.ProxyTypesBehavior());
_service = (Microsoft.Xrm.Sdk.IOrganizationService)serviceproxy;
}
return _service;
}
|
Note : Above written CreateService() method connects from Microsoft dynamic and return IOrganizationService which will be use for perform operation on CRM entity.
Step 12
Now I am going to create an Action method in MVC controller and write the code on this action method for fetch the "Account" entity record from CRM and display over their View.
Step 13 |
Note : In my next article I will describe how to create custom entity over Microsoft dynamics 365 and perform CRUD operation on that entity.
good to know, very well explain step by step, thanks for sharing...
ReplyDelete