locked
Retrieve By Id - get deactivated records too RRS feed

  • Question

  • Hi,

    I am using the following function to retrive entity attributes by Id. Nowhere do I specify that I need only active records. But, the query results do not include deactivated records. Any poniters?Thanks

     

    function RetrieveEntityById(prmEntityName, prmEntityId, prmEntityColumns)

        var resultXml, errorCount, msg, xmlHttpRequest, arrayEntityColumns, xmlEntityColumns; 
        arrayEntityColumns = prmEntityColumns.split(","); 
        for (var i = 0; i < arrayEntityColumns.length; i++) {
            xmlEntityColumns += "<q1:Attribute>" + arrayEntityColumns[i] + "</q1:Attribute>";
        } 
        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>" +
        "<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
        "<entityName>" + prmEntityName + "</entityName>" +
        "<id>" + prmEntityId + "</id>" +
        "<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>" +
        "<q1:Attributes>" +
        xmlEntityColumns +
       "</q1:Attributes>" +
        "</columnSet>" +
        "</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;
            alert("Error Message : " + msg);
        }
        else {
            return resultXml;
        }
    }

    Friday, February 3, 2012 11:03 PM

Answers

All replies