Most 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;
var EntityName=”product”;
var xmlHttpRequest;
FetchID =crmForm.all.[name of your lookup field].DataValue[0].id
var AttributeNameList = new Array(‘vendorname’);
var authenticationHeader = GenerateAuthenticationHeader();
//Prepare the SOAP message.
var xml = “<?xml version=’1.0′ encoding=’utf-8′?>” +
“<soap:Envelope xmlns:soap=’http://schemas.xmlsoap.org/soap/envelope/'” +
” xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance'” +
” xmlns:xsd=’http://www.w3.org/2001/XMLSchema’>”+
authenticationHeader +
“<soap:Body>” +
“<Retrieve xmlns=’http://schemas.microsoft.com/crm/2007/WebServices’>” +
“<entityName>”+EntityName+”</entityName>” +
“<id>” + FetchID + “</id>” +
“<columnSet xmlns:q1=’http://schemas.microsoft.com/crm/2006/Query’ xsi:type=’q1:ColumnSet’>” +
“<q1:Attributes>”;
for (var i = 0; i < AttributeNameList.length; i++) {
xml = xml +
‘<q1:Attribute>’ + AttributeNameList[i] + ‘</q1:Attribute>’;
}
xml = xml +
‘</q1:Attributes></columnSet>’;
xml = xml +
“</Retrieve></soap:Body></soap:Envelope>”;
//call function to create Soap Request to ms crm webservice
xmlHttpRequest =new ActiveXObject(“Msxml2.XMLHTTP”);
xmlHttpRequest.Open(“POST”, “/mscrmservices/2007/CrmService.asmx”, false);
xmlHttpRequest.setRequestHeader(“SOAPAction”, “http://schemas.microsoft.com/crm/2007/WebServices/Retrieve”);
xmlHttpRequest.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);
xmlHttpRequest.setRequestHeader(“Content-Length”, xml.length);
xmlHttpRequest.send(xml);
resultXml = xmlHttpRequest.responseXML;
var errorCount = resultXml.selectNodes(‘//error’).length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode(‘//description’).nodeTypedValue; //Process and display the results.
}
else
{
if (resultXml.selectSingleNode(‘//q1:vendorname’) != null)
crmForm.all.[customfieldnametostorevendorname].DataValue = resultXml.selectSingleNode(‘//q1:vendorname’).nodeTypedValue; }}}
_____________________________________________________
May be this code can help somebody at right time.
Best of luck !!! 🙂