Skip to main content

Posts

Showing posts from September, 2018

Inserting or updating bulk records in CRM 365 through C#

For some scenarios we would be having some requirements where multiple records needs to be created which can take number of iterations. To user service.create() method would affect the performance significantly. So we need to executemultiple request. Below is the code for the executemultiple() method usage. To create contact. Same can be used for other entities as well. Here i am selecting record from grid and looping through the selected records.             Entity                                    contact = new Entity();             EntityReferenceCollection   relatedEntities = new EntityReferenceCollection();             Relationship                          relationship = new Relationship("account_primary_contact");             String                                    bdate;             Int32                                     rowcount = dataGrid.SelectedItems.Count;             DataRowView                      rw;                      AccountManager     

Retrieving records from CRM 365 through c#

There are scenarios where you would want to retrieve records based on some condition. To do that with the use of C#,below code can be used. For example i have used account entity.                 QueryExpression query = new QueryExpression                { EntityName = "account", ColumnSet = new ColumnSet("name", "accountid") };                         ConditionExpression condition1 = new ConditionExpression();                 condition1.AttributeName = "name";                 condition1.Operator = ConditionOperator.Equal;                 condition1.Values.Add("Your filter value");                 FilterExpression filter1 = new FilterExpression();                 filter1.Conditions.Add(condition1);                 query.Criteria.AddFilter(filter1);                         EntityCollection accountname = _service.RetrieveMultiple(query); Other example with contact entity.               QueryExpression query = new Qu

Connecting to CRM 365 through C#

To logging in to CRM 365 through c# we need to use below code. For this purpose i have created a method. After adding the reference libraries in the project used below code to login.   public static void ConnectToMSCRM(string UserName, string Password, string SoapOrgServiceUri)         {             try             {                 IOrganizationService                      _service;                 ClientCredentials credentials         = new ClientCredentials();                 credentials.UserName.UserName  = UserName;                 credentials.UserName.Password    = Password;                 Uri serviceUri                                 = new Uri(SoapOrgServiceUri);                 OrganizationServiceProxy proxy   = new OrganizationServiceProxy(serviceUri, null, credentials, null);                 proxy.EnableProxyTypes();                 _service                                           = (IOrganizationService)proxy;             }             catch (Exception

Installing libraries for Dynamics CRM 365 development

To do the customization for Dynamics CRM 365 and to add new forms with functionality we need to install nuget in visual studio. Previously we used to download the CRM SDK for development. Now its not the same for 365. For this tutorial. Create a new project where you will be adding your code and customization. I am creating a WPF application for this scenario. Once the project is created, go to "References" node and right click. And click on "Manage NuGet Packages". New window will be opened. Search for "Microsoft.CrmSdk.CoreAssemblies v9.0.2.4" and "Microsoft.CrmSdk.CoreAssemblies v9.0.2.4" these are the main assemblies i am using for my example. You can search for other as well and click on install. Once you do the installation. system will ask you to confirm and once you do that you will be able to use the library in your code.You can see the newly added library to "References" node. Happy D365.