|
13.09.2010, 21:27 | #1 |
Участник
|
То ли лыжи не едут то ли...
1. делаю запрос в договор - получаю ид клиента. 2. делаю запрос в клиента - получаю его имя. 3. создаю новый лукап. Верно ? или можно шаг 1 и 2 каким - то образом объединить ? пример запроса в шаге 1 : // Prepare variables for a contact to retrieve. var authenticationHeader = GenerateAuthenticationHeader(); // 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>new_dogovor</entityName>"+ "<id>"+dogovorid+"</id>"+ "<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+ "<q1:Attributes>"+ "<q1:Attribute>new_bizbizpdogovor</q1:Attribute>"+ "</q1:Attributes>"+ "</columnSet>"+ "</Retrieve>"+ "</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/Retrieve"); 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); } // Display the retrieved value. else { alert(resultXml.selectSingleNode("//q1:new_bizbizpdogovor").nodeTypedValue); } |
|
13.09.2010, 21:47 | #2 |
Участник
|
В итоге получилось следующее:
Все работает, как всегда, БОЛЬШОЕ спасибо. if (crmForm.all.regardingobjectid.DataValue != null && crmForm.all.regardingobjectid.DataValue[0].typename == "new_dogovor") { crmForm.all.new_dogovor_vstrecha.DataValue=crmForm.all.regardingobjectid.DataValue; var dogovorid = crmForm.all.regardingobjectid.DataValue[0].id; //НАХОДИМ ИД КЛИЕНТА // Prepare variables for a contact to retrieve. var authenticationHeader = GenerateAuthenticationHeader(); // 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>new_dogovor</entityName>"+ "<id>"+dogovorid+"</id>"+ "<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+ "<q1:Attributes>"+ "<q1:Attribute>new_bizbizpdogovor</q1:Attribute>"+ "</q1:Attributes>"+ "</columnSet>"+ "</Retrieve>"+ "</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/Retrieve"); 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); } // Display the retrieved value. else { client_id= resultXml.selectSingleNode("//q1:new_bizbizpdogovor").nodeTypedValue; } // НАХОДИМ ИМЯ КЛИЕНТА ПО ЕГО ИД // 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>account</entityName>"+ "<id>"+client_id+"</id>"+ "<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+ "<q1:Attributes>"+ "<q1:Attribute>name</q1:Attribute>"+ "</q1:Attributes>"+ "</columnSet>"+ "</Retrieve>"+ "</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/Retrieve"); 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); } // Display the retrieved value. else { client_name= resultXml.selectSingleNode("//q1:name").nodeTypedValue; } //ДЕЛАЕМ НОВЫЙ ЛУКАП var lookupData = new Array(); var lookupItem= new Object(); lookupItem.id = client_id; lookupItem.typename = 'account'; lookupItem.name =client_name; lookupData[0] = lookupItem; crmForm.all.regardingobjectid.DataValue = lookupData; } Единственное, что приходит на ум, это через функцию получать ид и имя клиента. может как-то можно еще оптимизировать ? |
|
|
За это сообщение автора поблагодарили: mistah (1). |
13.09.2010, 22:12 | #3 |
Чайный пьяница
|
Попробуйте так:
Код: var client_id= resultXml.selectSingleNode("//q1:new_bizbizpdogovor").nodeTypedValue; var clientname= resultXml.selectSingleNode("//q1:new_bizbizpdogovor").getAttribute("name");
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством. Подписывайтесь на мой блог, twitter и YouTube канал. Пользуйтесь моим Ultimate Workflow Toolkit |
|
|
За это сообщение автора поблагодарили: mistah (1). |
14.09.2010, 10:26 | #4 |
Участник
|
Действительно ))
|
|
|
|