Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • Displaying Contact Information inside an iFrame (updated 3/31/07)

    Posted on March 22nd, 2006 mitch Print Print 4 comments

    My current project developed a requirement to display the Contact information on a tab on the Opportunity Entity.  Pretty simple, I thought, just create a new tab, throw on an iFrame and put a reference to one of the CRM pages that will display the contact for me.

    Pretty simple, on paper.  Execution turned it into something quite different that took me much longer that I would have hoped.  Anyway, here is the solution:

    1. Create a new tab and insert an iFrame.

    2. Set the URL field to: 

    http://server/_forms/readonly/readonly.aspx?obTypeCode=1&id=

    Which will make the form look like this: 

     

    3. In the Form's OnLoad Event, place the following code:

    if (crmForm.all.customerid.DataValue[0].id != null)
    {
    var ContactURL = "http://crm/_forms/readonly/readonly.aspx?objTypeCode=2&id="
    crmForm.all.IFRAME_ContactInfo.src = ContactURL + crmForm.all.customerid.DataValue[0].id;
    }

    This code will add the GUID or Unique ID to the URL for your iFrame so that when you click on the Contact Info tab, you see the contact information for the Contact associated with the Opportunity.

    It took me longer than usual because the information in the SDK was incorrect.  Thanks to Matt Whittemann for instructions to get around that issue and to Ronald Lemmen for information on how to display the read-only form.

    Revision: 3/31/2007:

    When you define the iFrame properties, you need to uncheck the Restrict cross-frame scripting in order for this to work properly.

     

    References: 

    Dynamics CRM 3.0 SDK: Client Programming, iFrame Support

    Dynamics CRM 3.0 SDK: Client Programming, URL Addressable Forms

    Dynamics CRM 3.0 SDK: Client Programming, Lookup Field Types

    CRM newsgroup post

    New Example of Javascript OnChange Code For CRM 3.0

     

     

    Customization, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    3,654 views
     

    4 responses to “Displaying Contact Information inside an iFrame (updated 3/31/07)”

    1. i get this error when the form loads:
      Server Error in '/' Application.
      ——————————————————————————–

      The resource cannot be found.
      Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

      Requested Url: /_forms/readonly/readonly.aspx

      in the url field I entered ibiz:5555

    2. Jerry,

      Did you qualify ibiz:5555 with Http://? If not, then that is probably the issue. Try:

      http://ibiz:5555

      and let me know what happens.

      Mitch

    3. [...] This is a revision to an article from March, 2006. [...]

    4. I am able to get the read only form to show up in the IFrame on the opportunity edit form but the form in the IFrame remains blank with a blue background. The tabs for the form in the IFrame show but if you click on those, the form remains blank with a blue back ground. The form in the IFrame does show that it is finding the record as evidenced by the "Contact: John Smith" in the upper left of the embedded form.
      Please comment.

    Leave a reply