web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Display Email Description in IFrame on Case form

(0) ShareShare
ReportReport
Posted on by 335

I had a perfectly functioning Case form that displayed the email message of an Email To Case queue.  We just changed our CRM deployment to Claims based authentication (IFD) with ADFS and now I receive the error Access Denied when trying to access the innerHTML of the IFrame. (Code Below)

function DoOnLoad()
{
    var isemailcase =  Xrm.Page.getAttribute("caseorigincode").getValue();
    var x = Xrm.Page.ui.controls.get("IFRAME_EmailBody").getObject();
    var y=(x.contentWindow || x.contentDocument);
    var element = Xrm.Page.getControl("description");
    if (isemailcase == 2) {
        if (y.document)y=y.document;
        var attr = Xrm.Page.data.entity.attributes.get("description");
        y.body.innerHTML = attr.getValue();
        element .setVisible(false);
    }
}

I did some research and found that I cannot talk directly to the IFrame, I have to use Cross Domain Communication with messages.  I found an example that I tried to modify to my requirements and cannot make it work.  Furthermore,  I get no errors so I do not know what I am doing wrong.  My guess is that I an writing to the innerHTML after the IFrame is loaded and so the new HTML body is not showing.  I am just not very good with Javascript... can someone help me figure this out???  Thank you so much.  Here is my code:

Form Properties OnLoad:

function DoOnLoad()
{
    var isemailcase =  Xrm.Page.getAttribute("caseorigincode").getValue();
    var x = Xrm.Page.ui.controls.get("IFRAME_EmailBody").getObject();
    var element = Xrm.Page.getControl("description");

    if (isemailcase == 2) {
        var attr = Xrm.Page.data.entity.attributes.get("description");
        x.contentWindow.postMessage(attr.getValue(), "*")
        element .setVisible(false);
    }
}

Form Properties OnSave:

function receiveMessage(e) {
    var x = Xrm.Page.ui.controls.get("IFRAME_EmailBody").getObject();
    var y=(x.contentWindow || x.contentDocument);
    if (e.origin == 'https://freya.jensenonline.com' || e.origin == 'https://jdscrm.jensenonline.com'){
        y.body.innerHTML = e.data;
    }
}
window.attachEvent("onmessage", receiveMessage);

 

*This post is locked for comments

I have the same question (0)
  • Gus Gonzalez Profile Picture
    27,113 on at

    Corey,

    Try the procedure described on the link below and maybe it will help solve this issue:

    www.zero2ten.com/.../Microsoft-Dynamics-CRM-2011-Help-doesn-t-work-after-Internet-Facing-Deployment.aspx

    Good Luck!

  • Cory Bonallo Profile Picture
    335 on at

    So you are saying my orginal code should work after this?  We are getting this internally through IFD. Internal being 'https://freya.jensenonline.com'

     Tried it and still the same error.  Help is working!  But I believe it was anyway.

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans