This is a example for retrieve product description on selection of Product.
apply this code to change event of line item of Opportunity, Quote, Sales Order and Invoice.
var Product = crmForm.all.productid.DataValue;
if(Product !=null)
{
var xml = "" +
"" +
"<soap:envelope soap="\"http://schemas.xmlsoap.org/soap/envelope/\"" xsi="\"http://www.w3.org/2001/XMLSchema-instance\"" xsd="\"http://www.w3.org/2001/XMLSchema\"">" +
GenerateAuthenticationHeader() +
" <soap:body>" +
" <retrievemultiple xmlns="\"http://schemas.microsoft.com/crm/2007/WebServices\"">" +
" <query q1="\"http://schemas.microsoft.com/crm/2006/Query\"" type="\"q1:QueryExpression\"">" +
" <q1:entityname>product</q1:entityname>" +
" <q1:columnset type="\"q1:ColumnSet\"">" +
" <q1:attributes>" +
" <q1:attribute>name</q1:attribute>" +
" <q1:attribute>description</q1:attribute>" +
" <q1:attribute>organizationid</q1:attribute>" +
" </q1:attributes>" +
" </q1:columnset>" +
" <q1:distinct>false</q1:distinct>" +
" <q1:criteria>" +
" <q1:filteroperator>And</q1:filteroperator>" +
" <q1:conditions>" +
" <q1:condition>" +
" <q1:attributename>productid</q1:attributename>" +
" <q1:operator>Equal</q1:operator>" +
" <q1:values>" +
" <q1:value type="xsd:string">" + Product[0].id+ "</q1:value>" +
" </q1:values>" +
" </q1:condition>" +
" </q1:conditions>" +
" </q1:criteria>" +
" </query>" +
" </retrievemultiple>" +
" </soap:body>" +
"</soap:envelope>" +
"";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
var entityNode = resultXml.selectSingleNode("//RetrieveMultipleResult/BusinessEntities/BusinessEntity");
var ProductNameNode = entityNode.selectSingleNode("q1:name");
var ProductDescriptionNode = entityNode.selectSingleNode("q1:description");
var organizationIdNode = entityNode.selectSingleNode("q1:organizationid");
var description= (ProductDescriptionNode== null) ? null : ProductDescriptionNode.text;
crmForm.all.productdescription.value = description;
}
Monday, March 2, 2009
Subscribe to:
Posts (Atom)