none
Retrieving values from an IFrame

    Pregunta

  • HI

     

    We have an IFrame embedded within a form.  What I want to do is be able to retrieve some values which are set in a form in the IFrame and then insert them into some attributes on my CRM form.  I found an article on how to do this and followed the instructions.  The values are supposed to be retrieved on the form onSave event.  However, when I click on the Save button I get the following error message appearing:

     

    There was an error with this field's customized event.

    Field: crmForm

    Event: onSave

    Error: Permission denied.

     

    I have ensured that the Restrict cross-frame scripting tick box is unchecked in the IFrame's properties page.  Where else could the problem lie?  I would appreciate if anyone has any advice on this.

     

    Many thanks,

     

    Dougy

    viernes, 23 de enero de 2009 9:36

Respuestas

  •  

    You can do that from within the IFRAME and avoid any permission issues.
    Inside the IFRAME add the following code:

     

    Code Snippet

     

    <script>

    function iframeOnLoad()
    {
        top.crmForm.attachEvent( “onsave” , OnCrmFormSave );
    }

    function OnCrmFormSave()
    {
        top.crmForm.someattribute.DataValue = document.all.iframeField.value;
        return true;
    }

    </script>


    <body onload=”iframeOnload();”>


     

     

    viernes, 23 de enero de 2009 9:54
  • Hi

     

    We ended up getting it working using a .Net solution instead of JavaScript one.  When the IFrame loads it inserts the values into the record's entry in the CRM database instead of just entering it into the form.  For some reason we were still getting a permissions issue with the JavaScript method which was driving us up the wall.  Anyway, many thanks to everyone who replied.

     

    Cheers,

     

    Douglas

     

    martes, 27 de enero de 2009 16:27

Todas las respuestas

  •  

    You can do that from within the IFRAME and avoid any permission issues.
    Inside the IFRAME add the following code:

     

    Code Snippet

     

    <script>

    function iframeOnLoad()
    {
        top.crmForm.attachEvent( “onsave” , OnCrmFormSave );
    }

    function OnCrmFormSave()
    {
        top.crmForm.someattribute.DataValue = document.all.iframeField.value;
        return true;
    }

    </script>


    <body onload=”iframeOnload();”>


     

     

    viernes, 23 de enero de 2009 9:54
  • Adi

     

    Thanks again for replying so promptly.  I tried as you suggested but I am still getting a permissions error on the form.  When the CRM form loads there is a scripting error highlighted in the bottom left of the screen.  When you look at the message it says:

     

    Line: 13

    Char: 5

    Error: Permission Denied

    Code: 0

    URL: URL of page...

     

    The line mentioned in the error message is the attachEvent line of your script.

     

    The IFrame site is on the same machine as the CRM application but in a different application.

     

    Thanks again,

     

    Dougy

    viernes, 23 de enero de 2009 10:56
  • Do you refer to the iframe url from a virtual directory under the isv folder? e.g. /orgname/isv/myotherapp/someiframeurl.aspx
    How about setting the iframe url in the trusted sites…


     

     

    viernes, 23 de enero de 2009 11:01
  • Hi.

     

    do you use a relative path to your custompage in the iframe?

    perhaps this will help

     

     

    viernes, 23 de enero de 2009 20:19
  • You might have forgotten to append the organization name to the url e.g. prependOrgName(“/isv/yourpage.aspx”);


     

     

    viernes, 23 de enero de 2009 21:00
  • Hi

     

    The IFrame isn't actually in the ISV folder.  It's a separate application installed on the same server as the CRM installation though.  I have added the IFrame site to the Intranet Zone in Internet Explorer but the problem still persists.  The IFrame URL is in the form:

     

    http://server/IFrames/IFrame_page.aspx

     

    Problem still coming up saying that that there is a Permission Denied error on the line:

     

    Code Snippet
    top.crmForm.attachEvent(
    'onsave', OnCrmFormSave);

     

     

     

    Thanks again,

     

    Douglas

    lunes, 26 de enero de 2009 14:36
  •  

    Try removing the attachevent code and referencing your parent form like this

     

    Code Snippet

    //return the value you are going to set (use for debug only)

    alert(this.document.forms[0].id);

     

    //set the value on the parent document

    parent.document.forms[0].all.new_Field.DataValue = this.document.forms[0].id;

     

     

     

    The actual save will be prompted by CRM as you have changed a form value (if you have been successful).  Normally errors in Javascript tend to show up on the wrong line, so if you are getting an error on line 90, try looking at line 89...that sometimes will point you in a better direction.

    lunes, 26 de enero de 2009 17:02
  • Assuming you are working with the account entity, create an html file as below and add it to an iframe within the account form...

     

    The code below will take the value of textbox "mybox" from the form "myform" and assign it to the Account Entity websiteurl property.  Hope this helps!

     

    Code Snippet

    <html>
    <body>
    <script language="javascript" type="text/javascript">
    function doThis()
    {
    showAlert(); //comment this line out later.
    parent.document.forms[0].all.websiteurl.DataValue =document.forms[0].mybox.value;
    }
    </script>
    <script language="javascript" type="text/javascript">
    function showAlert() {
     alert(document.forms[0].mybox.value);
    }
    </script>
     
    <form id="myform">
    <input id="mybox"></input>
    <input type="button" value="Click here" onClick="doThis();">
    </form>
    </body>
    </html>

     

     

    martes, 27 de enero de 2009 8:45
  • Hi

     

    We ended up getting it working using a .Net solution instead of JavaScript one.  When the IFrame loads it inserts the values into the record's entry in the CRM database instead of just entering it into the form.  For some reason we were still getting a permissions issue with the JavaScript method which was driving us up the wall.  Anyway, many thanks to everyone who replied.

     

    Cheers,

     

    Douglas

     

    martes, 27 de enero de 2009 16:27
  • I can confirm that using the code as provided by Adi does not work for IE8 and most likely newer browsers. This is due to the restriction of cross domain scripting, even if this would be allowed with the checkbox in CRM. For now, I can only see that using buttons to open popup windows and solving the integration serverside is the way to go.

    Kind regards,

    Ronald Lemmen


    Ronald Lemmen
    Microsoft Dynamics CRM MVP
    http://www.ronaldlemmen.com
    lunes, 12 de abril de 2010 14:50
  • we get this too if we use  FQDN instead of the actual path

    http://server.domain.com/webpage.aspx  returns permission issue

    http://server/webpage.aspx does not

     

    a real pain in the ____ if you have all your clients setup using the FQDN.


    Withers
    lunes, 12 de abril de 2010 16:47
  • Hi Douglas,

     

    I have a similar situation. I would like to know how you achieved it through .Net code.

    Cheers,

    Archana

    miércoles, 22 de septiembre de 2010 6:09