02.06.2008, 09:03 | #20 |
Участник
|
Цитата:
Откуда взялось GenerateAuthenticationHeader?
Цитата:
var ownerLookupItem = new Array;
ownerLookupItem = crmForm.all.ownerid.DataValue; var lookupData = new Array(); var bUnitLookupItem= new Object(); var debug = false; if (ownerLookupItem != null) { if (ownerLookupItem[0] != null) { var oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); var serverurl = "http://inftb:5555/"; sGUID=ownerLookupItem[0].id; if (sGUID != null) { var sEntityName="systemuser"; var sAttributeName="businessunitid"; var bUID =""; if(debug) crmForm.all.new_debug.DataValue = sEntityName + " | " + sGUID + " | "+ sAttributeName; bUID = GetAttributeValue(sEntityName, sGUID, sAttributeName); var bUEntityName ="businessunit"; var bUEntityType ="name"; if(debug) crmForm.all.new_debug.DataValue +=bUEntityName + " | " + bUID + " | "+ bUEntityType; var bUName = GetAttributeValue(bUEntityName, bUID, bUEntityType); bUnitLookupItem.id = bUID; bUnitLookupItem.typename = bUEntityName; bUnitLookupItem.name = bUName; lookupData[0] = bUnitLookupItem; crmForm.all.new_businessunit_phonecall.DataValue = lookupData; if(debug) crmForm.all.new_debug.DataValue += " >>" + lookupData[0].id + " | "+ lookupData[0].name; } } else { //alert("crmForm.all.ownerid is Null"); } } function GetAttributeValue(sEntityName, sGUID, sAttributeName) { var xml = ""; xml +="<?xml version=\"1.0\" encoding=\"utf-8\"?>"; xml +="<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\">"; xml += GenerateAuthenticationHeader(); xml +="<soap:Body>"; xml +="<entityName xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" + sEntityName + "</entityName>"; xml +="<id xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" + sGUID + "</id>"; xml +="<columnSet xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\" xmlns:q=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q:ColumnSet\">"; xml +="<q:Attributes>"; xml +="<q:Attribute>" + sAttributeName + "</q:Attribute>"; xml +="</q:Attributes>"; xml +="</columnSet>"; xml +="</soap:Body>"; xml +="</soap:Envelope>"; var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttpRequest.Open("POST", serverurl + "/mscrmservices/2006/CrmService.asmx", false); xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/Retrieve"); xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlHttpRequest.setRequestHeader("Content-Length", xml.length); xmlHttpRequest.send(xml); if(debug) crmForm.all.new_debug.DataValue +=xml; var doc = xmlHttpRequest.responseXML; if(debug) crmForm.all.new_debug.DataValue +=xmlHttpRequest.responseText; var retValue = ""; if (doc.selectSingleNode("//RetrieveResult/q1:" + sAttributeName) != null) retValue = doc.selectSingleNode("//RetrieveResult/q1:" + sAttributeName).text; else { if(debug) crmForm.all.new_debug.DataValue += xmlHttpRequest.responseXML; } return retValue; } |
|
|
|