{"id":918,"date":"2014-09-17T10:33:20","date_gmt":"2014-09-17T05:03:20","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=918"},"modified":"2014-09-17T10:33:20","modified_gmt":"2014-09-17T05:03:20","slug":"alternative-to-showmodaldialog","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2014\/09\/alternative-to-showmodaldialog\/","title":{"rendered":"Alternative to showModalDialog"},"content":{"rendered":"<p style=\"text-align: justify;\">Recent update to Chrome is such a hurtful update for CRM developers. It broke many of the CRM functionalities. It deprecated our favorite showModalDialog method.<\/p>\n<p style=\"text-align: justify;\">Due to the deprecation of showModalDialog method, we faced many issues. Out of those, we are going to talk about the CRM Lookup Dialog, that we used to get using showModalDialog. Since the showModalDialog is deprecated, how to get the CRM Lookup Dialog now? We can`t get the CRM Lookup Dialog again? How difficult would be to create the custom Lookup Dialog? hush&#8230;<\/p>\n<p style=\"text-align: justify;\">These are the questions haunting most of the developers. Let us help you out on this issue.<\/p>\n<p style=\"text-align: justify;\">Yeah! It&#8217;s still possible to get the CRM Lookup using script. But, instead of showModalDialog, we would be using another CRM method to get the Lookup.<\/p>\n<p style=\"text-align: justify;\">Let`s Look into it, previously we used to use showModalDialog method, now, we`ll use Xrm.Internal.openDialog method. Below code will explain you how to achieve it.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<p><code><br \/>\n\/\/MS-CRM Lookup<\/code><\/p>\n<p>function OpenLookup() {<\/p>\n<p>\/\/set entity choice<\/p>\n<p>var objectCode = &#8220;1084&#8221;;<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/prepare lookup url<\/p>\n<p>var url = &#8220;\/_controls\/lookup\/lookupsingle.aspx?objecttypes=&#8221; + objectCode;<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/Dialog Options would be set here<\/p>\n<p>var DialogOptions = new Xrm.DialogOptions();<\/p>\n<p>DialogOptions.width = 500;<\/p>\n<p>DialogOptions.height = 400;<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/open dialog<\/p>\n<p>Xrm.Internal.openDialog(Mscrm.CrmUri.create(url).toString(), DialogOptions, null, null, CallbackFunction);<\/p>\n<p>}<\/p>\n<p>\/\/Call back function for the Lookup<\/p>\n<p>function CallbackFunction(returnValue) {<\/p>\n<p>if (isValid(returnValue) &amp;&amp; isValid(returnValue.items) &amp;&amp; isValid(returnValue.items[0].id) &amp;&amp; isValid(returnValue.items[0].name)) {<\/p>\n<p>\/\/Set the Name in the textbox<\/p>\n<p>$(&#8220;#quoteId&#8221;).val(returnValue.items[0].name);<\/p>\n<p>\/\/Set the Id on the extra attribute called attr<\/p>\n<p>var guid = returnValue.items[0].id;<\/p>\n<p>$(&#8220;#quoteId&#8221;).attr(&#8220;guid&#8221;, guid);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">For this demo we are using an HTML webresource, on the HTML webresource we have a textbox and a Lookup button. On the click of the Lookup button, openLookup function is triggered. Callback function is where we are getting the selected record details. In the textbox we are setting the name and we have added an extra attribute called &#8220;<strong>guid<\/strong>&#8221; on the textbox field itself to store GUID of the record.<\/p>\n<p style=\"text-align: justify;\">Below is the actual screenshot of the demo:<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2014\/09\/13.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-925\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2014\/09\/13.jpg\" alt=\"1\" width=\"400\" height=\"323\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Wow, this simple it is now to get the Lookup Window Dialog. And, the best part, it is exactly like the OOB Lookup window.<\/p>\n<p style=\"text-align: justify;\">A part of the solution was suggested on <span style=\"color: #0000ff;\"><a title=\"CRM Roll Up\" href=\"https:\/\/www.linkedin.com\/groups\/crm-2011-roolup-15-on-21231.S.5914656497001836546\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color: #0000ff;\">this<\/span><\/a><\/span> thread by Rami Heleg.<\/p>\n<p style=\"text-align: justify;\"><strong>Note:\u00a0Use of <strong>Xrm.Internal<\/strong> is unsupported as per SDK.<\/strong><\/p>\n<p style=\"text-align: justify;\">Thanks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recent update to Chrome is such a hurtful update for CRM developers. It broke many of the CRM functionalities. It deprecated our favorite showModalDialog method. Due to the deprecation of showModalDialog method, we faced many issues. Out of those, we are going to talk about the CRM Lookup Dialog, that we used to get using\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2014\/09\/alternative-to-showmodaldialog\/\">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":[19,21,22,24],"tags":[392,502,1012],"class_list":["post-918","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm","category-dynamics-crm-2013","category-dynamics-crm-2015","category-dynamics-crm-2016","tag-crm-2013","tag-dialog","tag-lookup"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/918","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=918"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/918\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}