locked
Manipulating Iframe from JScript RRS feed

  • Question

  • Hi,

    We have a solution where we have an Iframe with an HTML page in it. This page har some fields that are filled by JS and this was working in CRM 2011, however after the lift to CRM 2013 something has changed. We are using the following code:

    var proxy = Xrm.Page.ui.controls.get("WebResource_WebProxy");
        if(proxy.getObject().contentWindow.document.getElementById("recipient1"))
          proxy.getObject().contentWindow.document.getElementById("recipient1").value = eMailAddress;

    Somehow it seems that the Xrm.Page.ui.controls.get isn't returning the object we expect anymore. Has anyone seen anything similar?

    Thanks


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, January 29, 2014 6:39 AM

All replies

  • 1. press F12 and locate on iframe and find its id

    2. if your code not working try

    var proxy=document.getelementbyid("controlid");

    alert(proxy);


    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Wednesday, January 29, 2014 8:23 AM
  • Hi Santosh,

    Thanks for helping but the proxy code you're proposing isn't really fetching the iframe from the form, is it?

    regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, January 29, 2014 9:17 AM
  • Hello,

    It could be the issue of loading of control , so just check if your control is returning object or not, if not wait for some time and check it again, you can write js code to wait for specified time.


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.


    Wednesday, January 29, 2014 10:52 AM
    Moderator
  •   var myVar = setInterval(function () {
                                        var myiframe =  parent.document.getElementsByid('controlid');

    if(myiframe !=null)

    {

    // do your code here

    }

                                    alert(myiframe );
                                        clearInterval(myVar);
                                    }, 1000);


    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Wednesday, January 29, 2014 11:05 AM
  • Hi all,

    Thanks for the input, it pointed me in some sort of direction. The problem is that the onload-script of the form is blocking the loading of the iframe so it will never load while the onload script is active. This is rather unfortunate since in CRM 2011 the entire form was loaded before the scripts were loaded. I've tried to do an onreadystatechange of the webresource/iframe but that won't trigger...

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, January 29, 2014 10:21 PM
  • Hi,

    We solved this with something that looked like Santosh's example but with a recursion calling for the same function with setTimeout from itself. This let the main script run through and the Iframe was loaded.

    Thanks for all help!


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Friday, January 31, 2014 8:54 AM