Показать сообщение отдельно
Старый 29.05.2008, 15:46   #9  
MFCшный Wizard is offline
MFCшный Wizard
Участник
 
16 / 10 (1) +
Регистрация: 27.05.2008
Путь добавила, результат не поменялся.
код следующий :
X++:
function GetAttributeValueByEntityId(entityName, entytiId, attributeName)
{
    var xml = '' + 
    '[?xml version=`1.0` encoding=`utf-8`?]' + '\r\n' + 
    '[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`]' + '\r\n' + 
    ' [soap:Body]' + '\r\n' + 
    ' [entityName xmlns=`http://schemas.microsoft.com/crm/2006/WebServices`]' + entityName + '[/entityName]' + '\r\n' + 
    ' [id xmlns=`http://schemas.microsoft.com/crm/2006/WebServices`]' + entytiId + '[/id]' + '\r\n' + 
    ' [columnSet xmlns=`http://schemas.microsoft.com/crm/2006/WebServices` xmlns:q=`http://schemas.microsoft.com/crm/2006/Query` xsi:type=`q:ColumnSet`]' + '\r\n' + 
    ' [q:Attributes]' + '\r\n' +
    ' [q:Attribute]' + attributeName + '[/q:Attribute]' + '\r\n' +
    ' [/q:Attributes]' + '\r\n' +
    ' [/columnSet]' + '\r\n' + 
    ' [/soap:Body]' + '\r\n' + 
    '[/soap:Envelope]' + 
    '';
    xml = xml.replace(/\[/gi, String.fromCharCode(60));
    xml = xml.replace(/\]/gi, String.fromCharCode(62));
    xml = xml.replace(/\`/gi, String.fromCharCode(34));
    var xmlHttpRequest = new ActiveXObject('Msxml2.XMLHTTP');
    xmlHttpRequest.Open('POST', '/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);
    var doc = xmlHttpRequest.responseXML;
  [B]alert(xmlHttpRequest.responseText);[/B] ---  ,  "Service was unable to process request"

   var retValue = '';
    if (doc.selectSingleNode('//RetrieveResult/' + attributeName) != null) retValue = doc.selectSingleNode('//RetrieveResult/' + attributeName).text;
    return retValue;
}

На буржуйских форумах смысл тот же: можно делать проект, а можно с помощью javascript брать атрибут сущности.
Для моей задачи мне достаточно брать нужный атрибут из сущности, и этот код вроде должен справляться, одна загвоздка - веб служба не запускается.