![]() |
#1 |
Участник
|
CRM Programmer: Embeded notification
Источник: http://crmpro.blogspot.com/2009/08/e...ification.html
============== We were needed some kind of notify message for user without any pop-up or an alerts. function CreateRequestObject() { if (window.XMLHttpRequest) { try { return new XMLHttpRequest(); } catch (e) { } } else if (window.ActiveXObject) { try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { } } } return null; } function RetrieveEntity(sEntityName, GUID, sAttributeNames) { var attributes = ""; if (sAttributeNames.length == 0) return null; for (var i = 0; i < sAttributeNames.length; i++) { attributes += "" + sAttributeNames[i] + ""; } var soapBody = "" + "" + "" + sEntityName + "" + "" + GUID + "" + "" + "" + attributes + "" + "" + "" + ""; var soapXml = ""; soapXml += GenerateAuthenticationHeader(); soapXml += soapBody; soapXml += ""; xmlhttp = CreateRequestObject(); 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/Retrieve"); xmlhttp.setRequestHeader("Content-Length", soapXml.length); xmlhttp.send(soapXml); // Capture the result. var resultXml = xmlhttp.responseXML; // Check for errors. var errorCount = resultXml.selectNodes('//error').length; if (errorCount != 0) { var msg = resultXml.selectSingleNode('//description').nodeTypedValue; alert(msg); return null; } // Display the retrieved value. else { var retEntityValues = new Array(); var retrieveNodes = resultXml.selectNodes("soap:Envelope/soap:Body/RetrieveResponse/RetrieveResult/q1:*"); for (var i = 0; i < retrieveNodes.length; i++) { var nodeName = retrieveNodes[0].baseName; var nodeValue = retrieveNodes[0].nodeTypedValue; retEntityValues[nodeName] = nodeValue; } return retEntityValues } } function AddNotification(noticationId, text) { if (crmForm.all.Notifications.all[noticationId] != null) crmForm.all.Notifications.all[noticationId + '_text'].innerHTML = text; else { crmForm.all.Notifications.innerHTML += ' ![]() '; crmForm.all.Notifications.style.display = 'block'; } } function RemoveNotification(noticationId) { if (crmForm.all.Notifications.all[noticationId] != null) { crmForm.all.Notifications.all[noticationId].removeNode(true); if (crmForm.all.Notifications.childNodes.length == 0) crmForm.all.Notifications.style.display = 'none'; } } var customer = crmForm.all.customerid; if (customer.DataValue != null && customer.DataValue[0].typename == 'account') { var cs = new Array(); cs[0] = 'new_attention'; var acc = RetrieveEntity('account', customer.DataValue[0].id, cs); if (acc != null && acc['new_attention'] == 1) { AddNotification('NotificationAccount', 'Клиент требует внимания! Для более подробной информации перейдите в карточку клиента.'); crmForm.all.customerid_d.getElementsByTagName('SPAN')[0].style.color = 'Red'; } else { RemoveNotification('NotificationAccount'); } } else { RemoveNotification('NotificationAccount'); } Источник: http://crmpro.blogspot.com/2009/08/e...ification.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|