Hi,
I was using the following code for getting the values using fech xml nd soap
It was working fine in 2011, but it's not supporting the 2013 beta version
can you please suggest me on this
function GetAttributeValue(enityName, attributeCode)
{
//debugger;
var fetchxmlvalue = '<fetch mapping="logical" distinct="true" > <entity name="' + enityName + '"><attribute name="' + attributeCode + '"/></entity></fetch>';
var fetchQuery = fetchxmlvalue;
var authenticationHeader = Xrm.Page.context.getAuthenticationHeader();
// 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>" +
"<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
"<fetchXml>" + _HtmlEncode(fetchQuery) + "</fetchXml>" +
"</Fetch>" +
"</soap:Body>" +
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Fetch");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0) {
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Process and display the results.
else {
// Capture the result and UnEncode it.
var resultSet = new String();
resultSet = resultXml.text;
resultSet.replace('<', '<');
resultSet.replace('>', '>');
// Create an XML document that you can parse.
var oXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
oXmlDoc.async = false;
// Load the XML document that has the UnEncoded results.
oXmlDoc.loadXML(resultSet);
// Display the results.
var results = oXmlDoc.getElementsByTagName('result');
if (results.length > 0) {
return results[0].childNodes[0].nodeTypedValue;
}
}
}
Thanks
Rammohan