Hi All,
I am new comer in Dynamics CRM 2011, i want to know how to do query in Dynamics CRM 2011 using FetchXML by javascript? in v4.0 i can do this script for query records the entity :
//Where a new email is a reply, get the 1st queue in the originating email's 'To' partylist, where one exists. function getOriginatingEmailFirstQueue(originalEmailId) {var authenticationHeader = GenerateAuthenticationHeader();// Prepare the SOAP message.//PartyObjectTypeCode of 2020 = queue, ParticipationTypeMask of 2 = 'To'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><fetch mapping='logical'>" +"<entity name='email'>" +"<link-entity name='activityparty' from='activityid' to='activityid' link-type='inner'>" +"<attribute name='partyid'/>" +//"<attribute name='partyidname'/>"+"<filter type='and'>" +"<condition attribute='activityid' operator='eq' value='" + originalEmailId + "'/>" +"<condition attribute='partyobjecttypecode' operator='eq' value='2020'/>" +"<condition attribute='participationtypemask' operator='eq' value='2'/>" +"</filter>" +"</link-entity>" +"</entity>" +"</fetch></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);returnnull; }// 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');var queue = results[0].selectSingleNode('./activityid.partyid').nodeTypedValue;var queueName = results[0].selectSingleNode('./activityid.partyid').getAttribute('name');if (queue != null&& queue.length > 0) { queue = queue.replace('{', '').replace('}', '');//Create an array to set as the DataValue for the lookup control.var lookupData = new Array();//Create an Object add to the array.var lookupItem = new Object();//Set the id, typename, and name properties to the object. lookupItem.id = '{' + queue + '}'; lookupItem.typename = 'queue'; lookupItem.name = queueName;// Add the object to the array. lookupData[0] = lookupItem;// Set the value of the lookup field to the value of the array. crmForm.all.from.DataValue = lookupData;returntrue; }else { alert('no queue - is null');returnnull; } } }
please advise,
thanks,
Rory Glo.