Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Automatically assign email signature on CRM Email

75 views
Skip to first unread message

Bob Oliver

unread,
May 13, 2010, 11:40:13 AM5/13/10
to
First check out the original post by the original author here -
http://mscrm4ever.blogspot.com/2009/05/crm-40-embedding-user-signature-in-crm.html
- kudos goes in that direction.

Some people had a problem (including me). Got it fixed by one of our
dev's, but seing as its a popular request with our clients, wanted to
share the fix, and couldn't post it to the original site.

The instructions to make it work are in the link above. Remeber to
change the GUID below before you post it into your Email entity form.


var templateId = 'E4F6EE02-665E-DF11-9F40-001372FB23D1';

function Signature(companyTemplateId)
{
var sig = this;
var emailIframe;
var emailBody;
var header = GenerateAuthenticationHeader();

sig.TemplateId = companyTemplateId;

sig.Load = function()
{
try
{
var 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">' +
header +
' <soap:Body>' +
' <Execute xmlns="http://schemas.microsoft.com/crm/2007/
WebServices">' +
' <Request xsi:type="InstantiateTemplateRequest"
ReturnDynamicEntities="false">' +
' <TemplateId>' + sig.TemplateId + '</TemplateId>' +
' <ObjectType>' + crmForm.ownerid.DataValue[0].typename +'</
ObjectType>' +
' <ObjectId>' + crmForm.ownerid.DataValue[0].id + '</ObjectId>' +
' </Request>' +
' </Execute>' +
' </soap:Body>' +
'</soap:Envelope>';

// alert(xml);

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;
emailIframeReady();
}
}
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(templateId);
signature.Load();
}
}

OnCrmPageLoad();

0 new messages