{"id":1616,"date":"2015-08-17T11:22:42","date_gmt":"2015-08-17T05:52:42","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=1616"},"modified":"2015-08-17T11:22:42","modified_gmt":"2015-08-17T05:52:42","slug":"replicate-right-click-behavior-of-dynamics-crm-grid-on-custom-grids","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2015\/08\/replicate-right-click-behavior-of-dynamics-crm-grid-on-custom-grids\/","title":{"rendered":"Replicate Right Click behavior of Dynamics CRM Grid on Custom Grids"},"content":{"rendered":"<p>In Microsoft dynamics CRM, we have grids for each and every entity. And whenever we right-click on the grid, we get a contextual menu as shown in below screenshot.<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/08\/grid.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-1618 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/08\/grid.png\" alt=\"grid\" width=\"630\" height=\"215\" \/><\/a><\/p>\n<p>Below is the list of menus that we get:<\/p>\n<ul>\n<li>Open<\/li>\n<li>Open In a new window<\/li>\n<li>Copy a Link<\/li>\n<li>Email a Link<\/li>\n<li>Print<\/li>\n<li>Refresh List<\/li>\n<\/ul>\n<p>When we click on above options, we get the functionality as explained below.<\/p>\n<p><strong>Open: <\/strong>When we click on open in Dynamics CRM, a record gets open in same window<\/p>\n<p><strong>Open In a new window: <\/strong>When we click on this option, record gets open in new window<\/p>\n<p><strong>Email a Link: <\/strong>When we click on Email a Link option, it gets open in the default email application which contains the record URL.<\/p>\n<p><strong>Copy a Link: <\/strong>When we click on this option, it copies the record URL.<strong><em> Note: <\/em><\/strong><em>This only works in IE.<\/em><\/p>\n<p><strong>Print: <\/strong>On click of Print option, below page (with the all values pre-populated) will open\u00a0<a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/08\/grid11.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1619\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2015\/08\/grid11.png\" alt=\"grid1\" width=\"630\" height=\"273\" \/><\/a><\/p>\n<p><strong>Refresh List: <\/strong>This option refreshes the grid data.<\/p>\n<p>CRM is not restricted to only OOB Grids; we have the flexibility to add customs grids as well.<\/p>\n<p>We can add custom grids using Jquery, kendo, knockout grid etc.<\/p>\n<p>There may be a case, where you need to mimic the right click functionality (Contextual menu) as the OOB grids have.<\/p>\n<p>In this blog, we will discuss how to implement right click functionality same as in CRM on customs grids.<\/p>\n<p>Consider a scenario, where you have a custom grid for a custom entity say \u201c<strong>Project<\/strong>\u201d.<\/p>\n<p>Now, you need to imitate the contextual menu as we have for OOB grids.<\/p>\n<p>So in order to have these menus, we have to use contextual menu (For this demo we have used kendo UI context menu).<\/p>\n<p>After adding options like Open, Open in New Window etc. in the context menu, we have to add custom logic in order to make it behave the way as we have for OOB grids.<\/p>\n<p>Below is the implementation of most commonly used menus, similarly you can have other custom menus as well.<\/p>\n<p><span style=\"color: #800000;\"><strong>Open :\u00a0<\/strong><\/span>This option is used to open the record in the same window.<\/p>\n<p>In order to open the record in the same window, we will be using OOB functionality i.e. openEntityForm as shown below.<\/p>\n<p><strong>Xrm.Utility.openEntityForm(name, id)<\/strong><\/p>\n<p><strong>name: <\/strong>Name of the entity of the selected record in the grid.<\/p>\n<p><strong>id:<\/strong> GUID of the selected record in the grid that we want to open in the same window.<\/p>\n<p><strong><span style=\"color: #800000;\">Open In a new window:<\/span>\u00a0<\/strong>This option is used to open the record in the new window.<\/p>\n<p>In order to open the record in the new window, CRM 2015 SP1 has introduced the new parameter in the openEntityForm. For more details, you can view our previously posted <a href=\"https:\/\/www.inogic.com\/blog\/2015\/07\/support-to-open-an-entity-form-in-a-new-window-in-dynamics-crm-2015-sp1\/\">blog<\/a>.<\/p>\n<p>var options = {<\/p>\n<p>openInNewWindow : true<\/p>\n<p>};<\/p>\n<p>Xrm.Utility.openEntityForm(name, id, null, options)<\/p>\n<p><strong>name: <\/strong>Name of the entity of the selected record in the grid.<\/p>\n<p><strong>id: <\/strong>GUID of the selected record that we want to open in new window.<\/p>\n<p><strong><span style=\"color: #800000;\">Email a Link:<\/span>\u00a0<\/strong>This option basically opens the record URL in the default mail application.<\/p>\n<p>In order to achieve this, we have to follow the below mentioned steps.<\/p>\n<p>Here first we will create the record URL that we need to send through email.<\/p>\n<p>var recordURL = Xrm.Page.context.getClientUrl() + &#8220;\/main.aspx?etc=10001&amp;id=&#8221; + id + &#8220;&amp;pagetype=entityrecord&#8221;<\/p>\n<p><strong>etc:<\/strong> Specify unique entity type code of the selected record in the grid.<\/p>\n<p><strong>id: <\/strong>GUID of the selected record in the grid.<\/p>\n<p>The next step is to add the record URL in email body.<\/p>\n<p>window.location.href = &#8220;mailto:?body=&#8221; + recordURL;<\/p>\n<p><strong><span style=\"color: #800000;\">Copy a Link:<\/span>\u00a0<\/strong>This option copies the record URL on the clipboard.<\/p>\n<p>We can achieve this using below piece of code.<\/p>\n<p>var recordURL = Xrm.Page.context.getClientUrl() + &#8220;\/main.aspx?etc=10001&amp;id=&#8221; + id + &#8220;&amp;pagetype=entityrecord&#8221;<\/p>\n<p><strong>etc:<\/strong> Specify unique entity type code of the selected record in the grid.<\/p>\n<p>If(window &amp;&amp; window.clipboardData)<\/p>\n<p>{<\/p>\n<p>window.clipboardData.setData(&#8220;Text&#8221;, recordURL);<\/p>\n<p>}<\/p>\n<p><strong><em>Note:<\/em><\/strong><em> This will only work in IE.<\/em><\/p>\n<p><strong><span style=\"color: #800000;\">Print:<\/span>\u00a0<\/strong>This option is intended to print the record.<\/p>\n<p>For printing the record, we are using the OOB functionality. On click of this option we will open the same page that gets open in CRM when we click Print in CRM.<\/p>\n<p>var url = Xrm.Page.context.getClientUrl() +&#8221;\/_forms\/print\/print.aspx?id=&#8221; + id + &#8220;&amp;objectType=10001&amp;subType=10001&#8221;<\/p>\n<p>window.open(url);<\/p>\n<p><strong>id<\/strong>: GUID of the selected record in the grid.<\/p>\n<p><strong>objectType<\/strong>: Specify unique entity type code of the selected record in the grid.<\/p>\n<p><strong>subType<\/strong>: Specify unique entity type code of the selected record in the grid.<\/p>\n<p><strong><span style=\"color: #800000;\">Refresh List:<\/span>\u00a0<\/strong>This option is to refresh the data in the grid.<\/p>\n<p>Call the same function that you have used to bind the data to the grid on click of this option.<\/p>\n<p>Hope it helps!<\/p>\n<p><span style=\"color: #800000;\">Now <a href=\"https:\/\/www.inogic.com\/blog\/2015\/08\/evaluate-dynamics-crm-and-bing-maps-integration-without-installation\/\" target=\"_blank\" rel=\"noopener noreferrer\">Evaluate Dynamics CRM and Bing Maps integration<\/a> without installation. For more details\u00a0get in touch with us on <a style=\"color: #800000;\" href=\"mailto:crm@inogic.com\" target=\"_blank\" rel=\"noopener noreferrer\">crm@inogic.com<\/a>.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Microsoft dynamics CRM, we have grids for each and every entity. And whenever we right-click on the grid, we get a contextual menu as shown in below screenshot. Below is the list of menus that we get: Open Open In a new window Copy a Link Email a Link Print Refresh List When we\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2015\/08\/replicate-right-click-behavior-of-dynamics-crm-grid-on-custom-grids\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15,19,21,22,24,33],"tags":[],"class_list":["post-1616","post","type-post","status-publish","format-standard","hentry","category-development","category-dynamics-crm","category-dynamics-crm-2013","category-dynamics-crm-2015","category-dynamics-crm-2016","category-javascript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/1616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=1616"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/1616\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=1616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=1616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=1616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}