{"id":8,"date":"2009-04-20T10:40:32","date_gmt":"2009-04-20T10:40:32","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=7"},"modified":"2009-04-20T10:40:32","modified_gmt":"2009-04-20T10:40:32","slug":"open-new-window-on-some-event","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=8","title":{"rendered":"Open new window on some event"},"content":{"rendered":"<p>i was just trying to open new service activity window on some event\u00a0 &amp; and after that i\u00a0was trying to\u00a0set customers according to the parent contact id<\/p>\n<p>i was just trying with<\/p>\n<p>window.open(&#8216;\/activities\/serviceappointment\/edit.aspx&#8217;);<\/p>\n<p>and i write following code to access paraent contactid look on form load event of service activity window.<\/p>\n<p>\/\/ to create lookup array<\/p>\n<p>var customer_lookup=new Array();<\/p>\n<p>\/\/ to check for new form<\/p>\n<p>if (crmForm.FormType == 1)<br \/>\n{<br \/>\n\u00a0\/\/ Check to confirm that the window.opener is present.<br \/>\n\u00a0if (window.opener)<br \/>\n\u00a0{<br \/>\n\u00a0 \/\/ Get the values of the parent form.<br \/>\n\u00a0 var oParentCrmForm = window.opener.document.all.crmForm;<br \/>\n\/\/To check Window.opner is calim entity or not<\/p>\n<p>\/\/10000 objectTypecode for my custom entity you can query ur organization database to check your custom entity&#8217;s objectTypecode<\/p>\n<p>if (oParentCrmForm &amp;&amp; oParentCrmForm.ObjectTypeCode == 10000)<br \/>\n{<br \/>\nvar customer_lookupItem= new Object();<br \/>\ncustomer_lookupItem.id=oParentCrmForm.all.asu_contactid.DataValue[0].id;<br \/>\ncustomer_lookupItem.typename=&#8217;Contact&#8217;;<br \/>\ncustomer_lookupItem.name=oParentCrmForm.all.asu_contactid.DataValue[0].name;<br \/>\ncustomer_lookup[0]=customer_lookupItem;<br \/>\ncrmForm.all.customers.DataValue=customer_lookup;<br \/>\n}<\/p>\n<p>}<br \/>\n}<\/p>\n<p>but i got one confusion when i was trying to open new service activity from action menu i was getting the customers name but when i was trying to open new service activity through my custom button it was not populating &#8230;..<\/p>\n<p>after some time i compare both the url Oppsssss i was missing organization name as i was working on multiorganization &#8230;&#8230;.<\/p>\n<p>so i changed my URL fo<\/p>\n<p>window.open(&#8216;\/&#8217;+ORG_UNIQUE_NAME+<span style=\"font-size:x-small;color:#0000ff;\"><span style=\"font-size:x-small;color:#0000ff;\"><span style=\"color:#000000;\">&#8216;\/<\/span><span style=\"color:#000000;\">activities\/serviceappointment\/edit.aspx&#8217;);<\/span><\/span><\/span><\/p>\n<p><span style=\"font-size:x-small;color:#0000ff;\"><span style=\"color:#000000;\">and finally it was working &#8230;&#8230;&#8230;.<\/span><\/span><\/p>\n<p><span style=\"font-size:x-small;color:#0000ff;\"><span style=\"font-size:x-small;color:#0000ff;\">\ud83d\ude42<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>i was just trying to open new service activity window on some event\u00a0 &amp; and after that i\u00a0was trying to\u00a0set customers according to the parent contact id i was just trying with window.open(&#8216;\/activities\/serviceappointment\/edit.aspx&#8217;); and i write following code to access paraent contactid look on form load event of service activity window. \/\/ to create lookup array var customer_lookup=new Array(); \/\/&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=8\">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":[25],"tags":[],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8"}],"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=8"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}