{"id":9410,"date":"2016-10-27T23:14:01","date_gmt":"2016-10-27T21:14:01","guid":{"rendered":"http:\/\/www.highcharts.com\/blog\/?p=9410"},"modified":"2026-01-12T09:11:24","modified_gmt":"2026-01-12T09:11:24","slug":"242-crm-dashboards","status":"publish","type":"post","link":"https:\/\/www.highcharts.com\/blog\/tutorials\/242-crm-dashboards\/","title":{"rendered":"Microsoft CRM Dashboards with Highcharts"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><b><strong>You are probably familiar with the term \u201cKey Performance Indicator\u201d or KPI for short.<\/strong><\/b> Executives use KPI to track how effective their company is in achieve its business goals. KPI could be revenue, cost, customer satisfaction, etc.<\/p>\n<p>Once you have many KPIs, the best way to track them, and have them support decision making, is to expose them via graphical dashboards.<\/p>\n<p>However, even if it is tempting to jump right into building charts, an organization must first tackle the challenge of picking KPIs to track. Too many, too few, or simply irrelevant data, are equally bad.<\/p>\n<p>In my work as a developer of Microsoft Dynamics CRM projects (Customer Relationship Management), solving the KPI puzzle is the first step of implementing dashboards.<\/p>\n<p>Whereas KPI selection is out of scope for this article, there is plenty of literature on that subject you can check out on your own. Instead, let\u2019s focus on the data visualization itself.<\/p>\n<h3>LET&#8217;S GET CHARTED<\/h3>\n<p>The default charting tools in Dynamics CRM help you to create a chart using a wizard, but it has its drawbacks. Among other things, it is hard to configure it to let the user select\/deselect a data-series in the chart.<\/p>\n<p>After evaluating many charting tools, I chose to implement Highcharts. It has many features by default; including the option to select\/deselect data-series in the chart.<\/p>\n<p><i><em>Dynamics CRM and Highcharts turned out to be a winning combination.<\/em><\/i><\/p>\n<h3>LET&#8217;S GET CODING<\/h3>\n<p>The best way to experience the beauty of having key features by default is by setting up an example: Let\u2019s create a simple dashboard with a pie chart, where the user picks two date ranges from the calendar, clicks on generate button, and then the chart is created.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/lh6.googleusercontent.com\/HlYb1YrfJL42AyxdrCiMkHZv_AWi1x95IRupHCpgdh_mbEX6nSfHsY-SXTcxJo_kefEfLEkt8jfoYTN2J8Kf8eUpc7yKeGlEKs-OoehJ7B3GU_0zF1mww3VFzfUx-IwDNc1s4aqH\" width=\"624\" height=\"224\" border=\"0\" \/><\/p>\n<p>It took me a few hours to finalize the project, so take your time to study the following code. It works for Dynamics CRM 2011 and 2013. (Download the complete code <a href=\"https:\/\/s3.amazonaws.com\/highsoftpictures\/_blog\/CRMDashboard\">here<\/a>):<\/p>\n<pre>&lt;html lang=\"en\"&gt;&lt;head&gt;\r\n &lt;link id=\"sharedaddy-css\" href=\"\/new_pikaday.css\" rel=\"stylesheet\" type=\"text\/css\" media=\"all\"&gt;\r\n &lt;script src=\"\/ClientGlobalContext.js.aspx\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script src=\"\/new_jquery1.6.min.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script src=\"\/new_sdk.rest.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script src=\"\/new_json2.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script src=\"\/new_sdk.metadata.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script src=\"\/new_highcharts.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script src=\"\/new_moment.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script src=\"\/new_pikaday.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script src=\"\/new_custom_reports_common.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n &lt;script type=\"text\/javascript\"&gt;\r\n var teamusers;\r\n function LeadSourceDataClass()\r\n {\r\n this.Name = '';\r\n this.Items = [];\r\n }\r\n...\r\n...\r\n...\r\n\r\n&lt;\/thead&gt;\r\n&lt;tbody&gt;\r\n&lt;tr&gt;\r\n&lt;td class=\"tableLabel\"&gt;From&lt;\/td&gt;\r\n&lt;td&gt;&lt;input id=\"fromPicker\" type=\"text\"&gt;&lt;\/td&gt;\r\n&lt;td class=\"tableLabel\"&gt;To&lt;\/td&gt;\r\n&lt;td&gt;&lt;input id=\"toPicker\" type=\"text\"&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;tr&gt;\r\n&lt;td&gt;&lt;\/td&gt;\r\n&lt;td&gt;&lt;input name=\"generateBtn\" id=\"generateBtn\" type=\"button\" value=\"Generate\"&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;\/tbody&gt;\r\n&lt;\/table&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/body&gt;&lt;\/html&gt;<\/pre>\n<p>Let\u2019s dive in:<br \/>\nAs you can see, there are several sections and libraries used. In the beginning, there are a bunch of scripts and a CSS file, where you can add web resources to Dynamics CRM.<\/p>\n<p>I use Pikaday library to handle the date range selection from a calendar. To interact with Dynamics API, I use the following libraries: ClientGlobalContext.js.aspx, sdk.rest.js, json2.js, and sdk.metadata.js. To handle the charting part of my dashboard, I use Highcharts.<\/p>\n<p>You can also notice that in the body of the code, there are HTML elements to help the user select data filters, such as the record creation date range.<\/p>\n<p>The main part of the code is between the script tag (<script><\/script>), as it handles the dashboard\u2019s data. I use the method getFilter under the method generateChart, to handle the user\u2019s selection from the data ranges input.<\/p>\n<p>Just to clarify some important point: The data come from a Odata Endpoint API, the query is being done via Odata API call. After all required data are fetched, the retrieveLeadsCompleted method sends the data and the chart\u2019s title to a helper method Helper.XRM.CustomReports.createPieChart. The helper method is in charge of setting up the chart using the Highcharts library, and voila the pie chart is created.<br \/>\nAs you&#8217;ll see, the feature I needed (select\/deselect graphs) is already there by default in Highcharts.<br \/>\nNow, I have a nice dashboard with a powerful data visualizations library :).<\/p>\n<p>Note:<br \/>\nI am also sharing the helperjs file (enjoy)<\/p>\n<pre>var Helper = Helper || {};\r\nHelper.XRM = Helper.XRM || {};\r\nHelper.XRM.CustomReports = Helper.XRM.CustomReports || {};\r\nHelper.XRM.CustomReports.MaxRecords = 100000;\r\n\/\/OptionSet Filter\r\n...<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Are you building dashboards with the right charting tools?<\/p>\n","protected":false},"author":36,"featured_media":10581,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"meta_title":"","meta_description":"","hc_selected_options":[],"footnotes":""},"categories":[210],"tags":[1010,1102],"coauthors":[740],"class_list":["post-9410","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-highcharts-dashboards","tag-software"],"_links":{"self":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/9410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/comments?post=9410"}],"version-history":[{"count":1,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/9410\/revisions"}],"predecessor-version":[{"id":29078,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/posts\/9410\/revisions\/29078"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media\/10581"}],"wp:attachment":[{"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/media?parent=9410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/categories?post=9410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/tags?post=9410"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.highcharts.com\/blog\/wp-json\/wp\/v2\/coauthors?post=9410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}