11.04.2011, 11:48 | #3 |
Moderator
|
Вот нашел у себя в коде функцию:
Код: var oTypeThis = crmForm.ObjectTypeCode; var oTypeThisName = crmForm.ObjectTypeName; var oTypeAssociated = Product; var oTypeAssociatedName = "product"; var oAssociationName = "new_productsForLead"; var oAssociationRecordName = "new_productsforlead"; function getAssociatedRecordsIds() { var oFetchXML = "<fetch mapping='logical'>" + "<entity name='" + oAssociationRecordName + "'>" + "<attribute name='" + oTypeAssociatedName + "id'/>" + "<filter type='and'>" + "<condition attribute='" + oTypeThisName + "id' operator='eq' value='" + crmForm.ObjectId + "'/>" + "</filter>" + "</entity>" + "</fetch>"; oFetchXML = oFetchXML.replace(/</g, '<'); oFetchXML = oFetchXML.replace(/>/g, '>'); var oSOAP = "<?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'>" + GenerateAuthenticationHeader() + "<soap:Body>" + "<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" + "<fetchXml>" + oFetchXML + "</fetchXml>" + "</Fetch>"+ "</soap:Body>"+ "</soap:Envelope>"; var oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); oXmlHttp.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); oXmlHttp.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Fetch"); oXmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); oXmlHttp.setRequestHeader("Content-Length", oSOAP.length); oXmlHttp.send(oSOAP); var oResponseText = oXmlHttp.responseXML.text; var oXmlDoc = new ActiveXObject("Microsoft.XMLDOM"); oXmlDoc.async = false; oXmlDoc.loadXML(oResponseText); var results = oXmlDoc.getElementsByTagName(oTypeAssociatedName + "id"); var associatedRecordsIds = new Array(results.length); for (var i = 0; i < results.length; i++) { associatedRecordsIds[i] = results[i].text; } return associatedRecordsIds; }
__________________
http://fixrm.wordpress.com, снятие/наведение порчи. Быстро, дорого, гарантия. MS Certified Dirty Magic Professional |
|
|
За это сообщение автора поблагодарили: Skyway (1). |
Теги |
javascript, soap, связь n:n |
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|