Posts

Showing posts from December, 2017

How to import CSV files into DataTable in C#

Below is code the which you can use for converting a csv file into Data Table in C#. This method also handles comma values inside a double quoted value. 1. Provide the file path of your csv file: string sCsvFilePath = @"C:\Downloads\Sample.csv"; 2. Call Custom Method: DataTable  dtTable = ConvertCSVtoDataTable(sFilePath); 3. Copy and Paste below: public   static   DataTable  ConvertCSVtoDataTable( string  sCsvFilePath) {      DataTable  dtTable =  new   DataTable ();      Regex  CSVParser =  new   Regex ( ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))" );      using  ( StreamReader  sr =  new   StreamReader (sCsvFilePath))     {          string [] headers = sr.ReadLine().Split( ',' );          foreach ...

How to bind Dynamics CRM data to dropdown using JavaScript/ HTML?

Image
In this blog, I 'll show how we can create a dropdown and bind it with value from Entity record values e.g we need to show all On-Demand process inside an entity as a dropdown list. So for this I have used 2 methods: ODATA and WebAPI call.. For Users using older version of CRM can use ODATA method. In this below example I am binding all system view in the dropdown inside an HTML web resource. Copy and paste code as below: 1. ODATA Method: <head>     <script type="text/javascript" src="/_common/ClientGlobalContext.js.aspx"></script> </head> <body style="overflow-wrap: break-word; height: 24px; word-wrap: break-word;">     <select id="viewdropdown" onchange="GetSelectedviewValue(this)" style="height:24px; width:495px; margin-left:16px">         <option selected="" value="Loading...">Loading...</option>     </select>     <script> ...

How to Write a Plugin when a Case is resolved with use Email Template in C#

In this blog, I am going to explain how we can fire a plugin on Resolved Case. Additionally I have added methods which shows how we can use Email Template too. Follwing points is important when working on resolved case plugin: 1. To fire a plugin when an incident is resolved we need to register the plugin in "Close" message for the incident entity. 2. In Input parameters of the context we need to check for IncidentResolution (this entity holds information of case being closed). Put below codes inside your Plugin, In my sample code I am creating an email activity after case gets resolved.         public class IncidentPostCloseHandler : IPlugin         {             public void Execute(IServiceProvider serviceProvider)             {                 try                 {       ...
go to top image