{"id":178,"date":"2010-05-06T07:11:17","date_gmt":"2010-05-06T07:11:17","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=178"},"modified":"2010-05-06T07:11:17","modified_gmt":"2010-05-06T07:11:17","slug":"show-associated-view-in-iframe-ms-crm-4-0","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=178","title":{"rendered":"Show Associated View in IFrame MS CRM 4.0"},"content":{"rendered":"<p>Some time we need to show associated view (1:N or N:N) in Iframe. I found a good article in <a href=\"https:\/\/community.dynamics.com\/blogs\/crmjimwang\/comments\/28067.aspx\">https:\/\/community.dynamics.com\/blogs\/crmjimwang\/comments\/28067.aspx<\/a> written by Jim Wang. After doing some little changes it worked like a charm for me. You can use this code for any associated view (1:N or N:N). You just need to get Left navigation item name that you can get through IE developer toolbar or Developer tools if you are using IE 8.<\/p>\n<p>\/\/Remember to change <strong>IFRAME_Name <\/strong>with name of iframe in your form.<\/p>\n<p>\/\/Check Form Type if it&#8217;s 1 than hide iframe.<\/p>\n<p>if (crmForm.FormType == 1) {<\/p>\n<p>\/\/To hide iframe<\/p>\n<p>\u00a0\u00a0\u00a0 crmForm.all.<strong>IFRAME_Name<\/strong>.parentNode.style.display = &#8216;none&#8217;;<\/p>\n<p>\u00a0 \u00a0\u00a0crmForm.all.<strong>IFRAME<\/strong>_<strong>Name<\/strong>.parentNode.parentNode.style.display = &#8216;none&#8217;;<\/p>\n<p>}<\/p>\n<p>else {<\/p>\n<p>\u00a0\u00a0\u00a0 \/\/Display associated view in Iframe<\/p>\n<p>\u00a0\u00a0\u00a0 var navId = &#8220;<strong>LeftNavigationItemName<\/strong>&#8220;; \/\/Remember to replace this with left navigation item name<\/p>\n<p>\u00a0\u00a0\u00a0 if (document.getElementById(navId) != null) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var tmp = document.getElementById(navId).onclick.toString();<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmp = tmp.substring(tmp.indexOf(&#8220;&#8216;&#8221;) + 1, tmp.indexOf(&#8220;;&#8221;));<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var loadArea = tmp.substring(0, tmp.indexOf(&#8220;&#8216;&#8221;));<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var roleOrd = (tmp.indexOf(&#8220;roleOrd&#8221;) == -1) ? -1 : tmp.substring(tmp.indexOf(&#8220;roleOrd&#8221;), tmp.lastIndexOf(&#8220;&#8216;&#8221;)).replace(&#8220;\\x3d&#8221;, &#8220;=&#8221;);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 crmForm.all.IFRAME_Name.src = (roleOrd == -1) ? GetFrameSrc(loadArea) : GetFrameSrc(loadArea) + &#8220;&amp;&#8221; + roleOrd;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/call function onreadystatechange to remove padding and scrollbar<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 crmForm.all.IFRAME_Name.attachEvent(&#8216;onreadystatechange&#8217;, RemovePadding);<\/p>\n<p>\u00a0\u00a0\u00a0 }<\/p>\n<p>}<\/p>\n<p>function GetFrameSrc(tabSet) {<\/p>\n<p>\u00a0\u00a0\u00a0 if (crmForm.ObjectId != null) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var id = crmForm.ObjectId;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var type = crmForm.ObjectTypeCode;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var security = crmFormSubmit.crmFormSubmitSecurity.value;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var path = document.location.pathname.substring(0, document.location.pathname.indexOf(&#8220;edit.aspx&#8221;)) + &#8220;areas.aspx?&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return (path + &#8220;oId=&#8221; + id + &#8220;&amp;oType=&#8221; + type + &#8220;&amp;security=&#8221; + security + &#8220;&amp;tabSet=&#8221; + tabSet);<\/p>\n<p>\u00a0\u00a0\u00a0 }<\/p>\n<p>\u00a0\u00a0\u00a0 else {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return &#8220;about:blank&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0 }<\/p>\n<p>}<\/p>\n<p>\/\/To remove padding<\/p>\n<p>function RemovePadding() {<\/p>\n<p>\u00a0\u00a0\u00a0 if (crmForm.all.IFRAME_Name.readyState == &#8216;complete&#8217;) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var IframeObject = crmForm.all.IFRAME_Name.contentWindow.document;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 IframeObject.body.scroll = &#8220;no&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 IframeObject.body.childNodes[0].rows[0].cells[0].style.padding = &#8220;0px&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0 }}<\/p>\n<p>Cheer \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time we need to show associated view (1:N or N:N) in Iframe. I found a good article in https:\/\/community.dynamics.com\/blogs\/crmjimwang\/comments\/28067.aspx written by Jim Wang. After doing some little changes it worked like a charm for me. You can use this code for any associated view (1:N or N:N). You just need to get Left navigation item name that you can&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=178\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[24,10],"tags":[],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/178"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=178"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}