|
![]() |
#1 |
Чайный пьяница
|
![]()
Вот такой код:
Код: function GetBUId(userid) { if (userid == null) return null; var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.open("POST", "/mscrmservices/2007/crmservice.asmx", false); xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Fetch"); 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'>"+ GenerateAuthenticationHeader() + " <soap:Body>" + "<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+ "<fetchXml> "+ "<fetch mapping='logical'> " + "<entity name='systemuser'> " + "<attribute name='businessunitid' /> " + "<filter type='and'> " + "<condition attribute='systemuserid' operator='eq' value='" + userid +"'/> " + "</filter> " + "</entity> " + "</fetch>"+ "</fetchXml>"+ "</Fetch>"+ "</soap:Body>"+ "</soap:Envelope>"; xmlhttp.setRequestHeader("Content-Length", xml.length); xmlhttp.send(xml); var resultSet = new String(xmlhttp.responseXml.text); resultSet.replace('<','<'); resultSet.replace('>','>'); var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.loadXML(resultSet); var lookupitem = new Object(); lookupitem.typename = "businessunit"; lookupitem.id = xmlDoc.selectSingleNode("//resultset/result/businessunitid").nodeValue; lookupitem.name = xmlDoc.selectSingleNode("//resultset/result/businessunitid").attributes.getNamedItem("name").text; retutn lookupItem; } if (crmForm.all.ownerid.DataValue != null && crmForm.all.ownerid.DataValue.length != 0 && crmForm.all.ownerid[0] != null) { var lookupData = new Array(); lookupData[0] = GetBUId(crmForm.all.ownerid[0].id); crmForm.all.new_businessunitid.DataValue = lookupData; }
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством. Подписывайтесь на мой блог, twitter и YouTube канал. Пользуйтесь моим Ultimate Workflow Toolkit |
|
|
За это сообщение автора поблагодарили: O_Chiner (1). |