31.05.2009, 06:07 | #1 |
Участник
|
mscrm4ever: CRM 4.0 Embedding User Signature in CRM Web Client
Источник: http://mscrm4ever.blogspot.com/2009/...re-in-crm.html
============== One of the main features that the CRM email web client is missing is an automatic stationary signature. Although a user (or an administrator) can create a predefined signature and embed it before sending the email the web client requires the user to fill the TO (or CC) field in advance and then pick out the signature template using the Insert Template button. For most of us who gotten used to using advanced editors like outlook this seems like a major step backwards. In order to enhance the user experience and demonstrate to strength and simplicity of dynamics while I’m at it I wrote a post that automates the process. The automated signature makes use of CRM’s email template feature. Once the Global email template (signature) is in place you need to extract its id (templateid) and use it in your code. In order to retrieve the template id you can run this following query against the filteredtemplate view: SELECT TEMPLATEID FROM FILTEREDTEMPLATE WHERE TITLE = ‘USER SIGNATURE’ The nice thing about dynamics is that most UI features also have an API manifestation. In this case it’s the ability to instantiate email templates by using the InstantiateTemplateRequest. The InstantiateTemplateRequest receives a templateid, objectid and objecttype. The objectid and type are used as context so the template is able to retrieve information that is specific to the recipient entity. Since we are only interested in the user information the objectid and type are field with the email owner which is the current user. Copy the following code to the email onload event and enjoy… function Signature(companyTemplateId) { var sig = this; var emailIframe; var emailBody; sig.TemplateId = companyTemplateId; sig.Load = function() { try { var xml = "" + "" + "" + GenerateAuthenticationHeader() + " " + " " + " " + " " + sig.TemplateId + "" + " " + crmForm.ownerid.DataValue[0].typename + "" + " " + crmForm.ownerid.DataValue[0].id + "" + " " + " " + " " + "" + ""; var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute"); xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlHttpRequest.setRequestHeader("Content-Length", xml.length); xmlHttpRequest.send(xml); var resultXml = xmlHttpRequest.responseXML; if (xmlHttpRequest.status == 200) { emailBody = resultXml.selectSingleNode("//q1:description").text; } } catch(err) { alert(err.description); } } function emailIframeReady() { if (emailIframe.readyState != 'complete') { return; } emailIframe.contentWindow.document.body.innerHTML = emailBody; } emailIframe = document.all.descriptionIFrame; emailIframe.onreadystatechange = emailIframeReady; } function OnCrmPageLoad() { if (crmForm.FormType == 1) { var signature = new Signature("30875359-3c4d-de11-9cf8-0003ff230264"); signature.Load(); } } OnCrmPageLoad(); Источник: http://mscrm4ever.blogspot.com/2009/...re-in-crm.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|