Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

load email template when an email activity is addded in contact

$
0
0

Hello All,

I'm using below code to load email template on, onload of email activity. But its giving me error as CreateXmlDocument is undefined.

function loadtemplate()
{
var emailTemplateToLoad = "E83BA87D-65B9-E211-A110-00155D019F1E";//guid of template
// Get Regarding object details
var RegardingItems =Xrm.Page.getAttribute("regardingobjectid").getValue();
var regardingObjectId = RegardingItems[0].id;
var regardingObjectType = RegardingItems[0].type;
var command = new RemoteCommand("EmailTemplateService", "GetInstantiatedEmailTemplate");
command.SetParameter("templateId", emailTemplateToLoad );
command.SetParameter("objectId", regardingObjectId);
command.SetParameter("objectTypeCode", regardingObjectType);
var result = command.Execute();
if (result.Success)
{
    var o = new Object();
    o.EmailBody = "";
    o.EmailSubject = "";
    if(typeof(result.ReturnValue) == "string")
    {
        oXml = CreateXmlDocument(false);
        oXml.loadXML(result.ReturnValue);
        crmForm.all.description.InsertValue(oXml.selectSingleNode("template/body").text);
        o.EmailSubject = oXml.selectSingleNode("template/subject").text;
    }
}

}

Please help me solve this problem.

Thanks and Regards. Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>