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

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.

 

Notes:

It is very important that the objTypeCode parameter match the CRM Entity type that you wish to display. For instance, if you wish to display a Contact in the iFrame, objTypeCode would equal 2.  If you wish to display an Account, objTypeCode would equal 1.  For a complete list of CRM Object Type Codes, visit the following link.

JavaScript is also case-sensitive, so make sure that you spell the parameter names exactly as you see above.

Conclusion:

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.

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