How to create a custom entity record using the values retrieved from iframe in crm 2011? RRS feed

  • Question

  • In Account form i have an iframe where you can enter 3 text field values and when clicking on save button on iframe i want to create a custom entity record retrieved using those values?
    Monday, July 22, 2013 8:26 AM

All replies

  • Hi jasmin,

    You can create a html web resource put 3 text boxes and a button. On clicking the button you can use REST endpoint to create the record.For that you can go through the following link.


    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful" Thank you, DT

    Monday, July 22, 2013 9:58 AM
  • How to retrieve html controls in frame using javascript?

    Monday, July 22, 2013 10:23 AM
  • create a web page and populate it in iframe 

    below is code to integrate web page with ms crm 


    ms crm

    Monday, July 22, 2013 10:47 AM
  • Hi Jasmin,

    You don't need to retrieve any controls from iframe. Just create a html web resource and add the controls and do all the logics which is creating the record inside that web resource which will be again called on click of the save button.

    Here I am asuming that the save button is on the web resource itself.Otherwise if you want to create record directly on save of the CRM form.Then you can get the webresource control by the following code.

     var webResource= Xrm.Page.ui.controls.get("WebResource_Name").getObject().contentWindow;

    and then from that you can get the control by the following line of code.

    var txtBoxVal=webResource.document.getElementById("txtBox").innerHTML;

    Please mark it as answer if it solves your problem

    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful" Thank you, DT

    Monday, July 22, 2013 10:53 AM
  • I have created an html page with three textboxes and a save button.But i don't know how to retrieve the html control values through javascript web resource.
    Monday, July 22, 2013 10:53 AM
  • you can also do it through the html web resource 

    ms crm

    Monday, July 22, 2013 12:34 PM
  • This is my html page.Is this the correct way to call the javascript webresource.When i click on save button i want to create a custom entity record based on these values.

    <script type="text/javascript" src="getIframeText.js"></script>
        <title>Previous History</title>
        <style type="text/css">
                font-family:Segoe UI;
                width: 220px;
                font-family:Segoe UI;
                width: 220px;
                font-family:Segoe UI;
                width: 220px;
                font-family:Segoe UI, Tahoma, Arial;
                width: 88px;
                width: 223px;
    <form id="history" class="style2">
    <table align="center"
        style="background-repeat: repeat-x; border-collapse: collapse;">
    <td> <label>Previously Used Product</label>  </td>
     <td class="style1">   <input type = "text"
                      id = "updt"
                      name = "usedpdt" /></td>     
    <td> <label>Want to Go For</label>  </td>
     <td class="style1">   <input type = "text"
                      id = "gfor"
                      name = "gofor" /></td> 
    <td> <label>Budget</label>  </td>
     <td class="style1">   <input type = "text"
                      id = "budgt"
                      name = "budget" /></td> 
    <td class="style1">
    <input type="button"


    Tuesday, July 23, 2013 4:29 AM
  • When i click on save button on iframe nothing happens.
    Tuesday, July 23, 2013 4:43 AM
  • There's a couple of ways of doing this. As mentioned earlier, you can add a call to the REST endpoint into your javascript code - this could take the form information and create a new record with the values entered. There's loads of resources out there about how to do this - my favourite is linked below:


    Alternatively, you could create 3 new attributes on the form which will take this information. You can then add some calls to them in your javascript in your iframe. You reference the attributes from the iframe javascript with the following line of code:

    window.parent.Xrm.Page.data.entity.attributes.get("attribute_name").setValue("Here is the value");

    In fact, adding the "window.parent." bit will let you access all of the CRM Xrm from your iframe. Once the values are in your entity, you can then do whatever you want with them in the CRM code but if the iframe ever happens to be run without being wrapped up in CRM, the javascript will error as, of course, the attributes you're referencing won't be there.

    I hope this helps.

    • Proposed as answer by Jon_Evans Tuesday, July 23, 2013 10:23 AM
    Tuesday, July 23, 2013 10:22 AM