Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 123975

Forum Post: RE: (CRM 4) Accessing product entity from product lookup in opportunityproduct(javascript)

$
0
0

I used this piece of code and got it to work.

function GetObjectAttribute(objectid, entityname, attribute) {

   // Preparer the SOAP message

   var message =

       [

       "<?xml version='1.0' encoding='utf-8'?>",

       "<soap:Envelope xmlns:soap='schemas.xmlsoap.org/.../&,

       " xmlns:xsi='www.w3.org/.../XMLSchema-instance&,

       " xmlns:xsd='www.w3.org/.../XMLSchema&,

       GenerateAuthenticationHeader(),

       "<soap:Body>",

       "<Retrieve xmlns='schemas.microsoft.com/.../WebServices&,

       "<entityName>",

       entityname,

       "</entityName>",

       "<id>",

       objectid,

       "</id>",

       "<columnSet xmlns:q1='schemas.microsoft.com/.../Query&,

       " xsi:type='q1:ColumnSet'>",

       "<q1:Attributes><q1:Attribute>",

       attribute,

       "</q1:Attribute></q1:Attributes>",

       "</columnSet></Retrieve>",

       "</soap:Body></soap:Envelope>"

       ].join("");

   var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

   xmlhttp.open("POST", "/MSCrmServices/2007/CrmService.asmx", false);

   xmlhttp.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../Retrieve");

   xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

   xmlhttp.setRequestHeader("Content-Length", message.length);

   xmlhttp.send(message);

   var result = xmlhttp.responseXML;

   var error = result.selectNodes('//error').length;

   if (error == 0) {

       var attributeNode = result.selectSingleNode('//q1:' + attribute);

       if (attributeNode != null) {

           return attributeNode.text;

       }

   }

   return null;

}

Thanks for the help.


Viewing all articles
Browse latest Browse all 123975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>