locked
Java script to support cross browser functionality RRS feed

  • Question

  • Hello Experts,

    function loadtemplate()
    {
    var formType = Xrm.Page.ui.getFormType();
    if (formType!= 1) {return;}
    var emailTemplateToLoad = "1A7DF4A2-51C8-E211-9BC9-AC162DB4BC72";
     
     
     
    // 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")
        {
       var nodePath = "//attributes/attribute";     
    var doc = new ActiveXObject("Microsoft.XMLDOM");
    doc.preserveWhiteSpace = true;
    doc.async = false;
    doc.loadXML(result.ReturnValue);
    params = new Array();
    var nodelist;
    nodelist = doc.selectNodes(nodePath);
    Xrm.Page.getAttribute("description").setValue(doc.selectSingleNode("template/body").text);
    
        }
    }
    var a = window.setTimeout(loadtemplate, 500);
    }

    Above is the code used to load email template on load of email form. But custom code validation tool is showing error in this script. ActiveX control will not be working in other browsers. How to find alternative for this.

    This is the screen shot of custom code validation tool. crmForm.all i have not used. Those lines are commented.


    Thanks and Regards. MadhuSudhan M

    Tuesday, August 20, 2013 9:39 AM

All replies