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