{"id":66,"date":"2009-12-09T11:54:17","date_gmt":"2009-12-09T11:54:17","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=66"},"modified":"2009-12-09T11:54:17","modified_gmt":"2009-12-09T11:54:17","slug":"get-production-information-based-on-product-id","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=66","title":{"rendered":"Get Production Information Based on ProductID"},"content":{"rendered":"<p>\u00a0Most of the time i found this question on microsoft forum to get product information based on productid. I have develped this code for the same requirement.<\/p>\n<p>You can just paste this code on the onchange event of the product lookup. You just need to chage field names accordingly.<\/p>\n<p>__________________________________________________<\/p>\n<p>GetProductInformation();<\/p>\n<p>function GetProductInformation()<\/p>\n<p>{<\/p>\n<p>var resultXml;<\/p>\n<p>var errorCount;<\/p>\n<p>var msg;<\/p>\n<p>var EntityName=&#8221;product&#8221;;<\/p>\n<p>var xmlHttpRequest;<\/p>\n<p>FetchID =crmForm.all.[name of your lookup field].DataValue[0].id<\/p>\n<p>var AttributeNameList = new Array(&#8216;vendorname&#8217;);<\/p>\n<p>var authenticationHeader = GenerateAuthenticationHeader();<\/p>\n<p>\/\/Prepare the SOAP message.<\/p>\n<p>var xml = &#8220;&lt;?xml version=&#8217;1.0&#8242; encoding=&#8217;utf-8&#8242;?&gt;&#8221; +<\/p>\n<p>&#8220;&lt;soap:Envelope xmlns:soap=&#8217;http:\/\/schemas.xmlsoap.org\/soap\/envelope\/'&#8221; +<\/p>\n<p>&#8221; xmlns:xsi=&#8217;http:\/\/www.w3.org\/2001\/XMLSchema-instance'&#8221; +<\/p>\n<p>&#8221; xmlns:xsd=&#8217;http:\/\/www.w3.org\/2001\/XMLSchema&#8217;&gt;&#8221;+<\/p>\n<p>authenticationHeader +<\/p>\n<p>&#8220;&lt;soap:Body&gt;&#8221; +<\/p>\n<p>&#8220;&lt;Retrieve xmlns=&#8217;http:\/\/schemas.microsoft.com\/crm\/2007\/WebServices&#8217;&gt;&#8221; +<\/p>\n<p>&#8220;&lt;entityName&gt;&#8221;+EntityName+&#8221;&lt;\/entityName&gt;&#8221; +<\/p>\n<p>&#8220;&lt;id&gt;&#8221; + FetchID + &#8220;&lt;\/id&gt;&#8221; +<\/p>\n<p>&#8220;&lt;columnSet xmlns:q1=&#8217;http:\/\/schemas.microsoft.com\/crm\/2006\/Query&#8217; xsi:type=&#8217;q1:ColumnSet&#8217;&gt;&#8221; +<\/p>\n<p>&#8220;&lt;q1:Attributes&gt;&#8221;;<\/p>\n<p>for (var i = 0; i &lt; AttributeNameList.length; i++) {<\/p>\n<p>xml = xml +<\/p>\n<p>&#8216;&lt;q1:Attribute&gt;&#8217; + AttributeNameList[i] + &#8216;&lt;\/q1:Attribute&gt;&#8217;;<\/p>\n<p>}<\/p>\n<p>xml = xml +<\/p>\n<p>&#8216;&lt;\/q1:Attributes&gt;&lt;\/columnSet&gt;&#8217;;<\/p>\n<p>xml = xml +<\/p>\n<p>&#8220;&lt;\/Retrieve&gt;&lt;\/soap:Body&gt;&lt;\/soap:Envelope&gt;&#8221;;<\/p>\n<p>\/\/call function to create Soap Request to ms crm webservice<\/p>\n<p>xmlHttpRequest =new ActiveXObject(&#8220;Msxml2.XMLHTTP&#8221;);<\/p>\n<p>xmlHttpRequest.Open(&#8220;POST&#8221;, &#8220;\/mscrmservices\/2007\/CrmService.asmx&#8221;, false);<\/p>\n<p>xmlHttpRequest.setRequestHeader(&#8220;SOAPAction&#8221;, &#8220;http:\/\/schemas.microsoft.com\/crm\/2007\/WebServices\/Retrieve&#8221;);<\/p>\n<p>xmlHttpRequest.setRequestHeader(&#8220;Content-Type&#8221;, &#8220;text\/xml; charset=utf-8&#8221;);<\/p>\n<p>xmlHttpRequest.setRequestHeader(&#8220;Content-Length&#8221;, xml.length);<\/p>\n<p>xmlHttpRequest.send(xml);<\/p>\n<p>resultXml = xmlHttpRequest.responseXML;<\/p>\n<p>var errorCount = resultXml.selectNodes(&#8216;\/\/error&#8217;).length;<\/p>\n<p>if (errorCount != 0)<\/p>\n<p>{<\/p>\n<p>var msg = resultXml.selectSingleNode(&#8216;\/\/description&#8217;).nodeTypedValue; \/\/Process and display the results.<\/p>\n<p>}<\/p>\n<p>else<\/p>\n<p>{<\/p>\n<p>if (resultXml.selectSingleNode(&#8216;\/\/q1:vendorname&#8217;) != null)<\/p>\n<p>crmForm.all.[customfieldnametostorevendorname].DataValue = resultXml.selectSingleNode(&#8216;\/\/q1:vendorname&#8217;).nodeTypedValue; }}}<\/p>\n<p>_____________________________________________________<\/p>\n<p>May be this code can help somebody at right time.<\/p>\n<p>Best of luck !!!\u00a0\u00a0\u00a0 \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0Most of the time i found this question on microsoft forum to get product information based on productid. I have develped this code for the same requirement. You can just paste this code on the onchange event of the product lookup. You just need to chage field names accordingly. __________________________________________________ GetProductInformation(); function GetProductInformation() { var resultXml; var errorCount; var msg;&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=66\">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\/66"}],"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=66"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}