Показать сообщение отдельно
Старый 29.09.2009, 11:01   #40  
Tarasov E is offline
Tarasov E
Участник
Аватар для Tarasov E
 
100 / 11 (1) +
Регистрация: 01.09.2009
Значит так: написал на основе данного запроса функцию по обновлению атрибута new_data в сущности new_web по нажатию на кнопку.
Далее привожу код функции:
Код:
//Обновление даты
function SetAttributeValueFromID(sEntityName, GUID)
    {

var contactId =GUID;
var data = (new Date()).getDate()+'/'+(new Date()).getMonth()+'/'+(new Date()).getYear()+'  '+(new Date()).getHours()+':'+(new Date()).getMinutes();
var authenticationHeader = GenerateAuthenticationHeader();
    
// Prepare the SOAP message.

    var xml = '';
 
    xml = 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 запроса.
     '<soap:Body>'+

     //Обновление атрибута
'<Update xmlns=\'http://schemas.microsoft.com/crm/2007/WebServices\'>'+ 
'<entity xsi:type=sEntityName>'+ 
'<new_data>\'+data+\'</new_data>'+ 
'<contactid>\'+contactId+\'</contactid>'+ 
'</entity>'+ 
'</Update>'+ 
'</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/Update');
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 a confirmation message and open the updated contact.
else
{
alert('Contact with id = '+contactId+' successfully updated.');
window.open('/sfa/conts/edit.aspx?id={'+contactId+'}');
}
}
 var a = getSelected('crmGrid');	

SetAttributeValueFromID('new_web', a);
После выполнения имею то, что на скрине, но обновления даты не происходит.
В чем может быть ошибка?
Изображения