-
Revised: Displaying Contact Information Inside an iFrame
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
New Example of Javascript OnChange Code For CRM 3.0
Customization, Dynamics CRM 4,154 views6 responses to “Revised: Displaying Contact Information Inside an iFrame”
-
Bas van Sluis September 22nd, 2006 at 13:14
Hello Mitch,
Great article. I have tested it with the contact form to show the originating lead information. I hope this would work because I want to read the notes from the lead. The notes are not converted when converting a lead to a contact.
This should be a great way to easily show the notes.
But samehow, the notes are not shown, not even when I try your example.
Is this the same at your situation.?
Regards,
Bas van Sluis
CRM-Resultants -
Bas,
Good news, bad news, and worse news:
Good News: You are correct.
Bad News: It IS NOT working.
Worse News: I've spent over an hour on it and I have no clue why it doesn't.I'll keep researching the issue, but for the moment, we need to consider this "by design" or a bug.
Mitch
-
Bas van Sluis September 23rd, 2006 at 06:40
Hi Mitch,
Same here, spend a lot of time to get this to work. I have no clue either. There is something diffente with notes compared to other entities. Maybe this is also the reason why notes are not converted when converting a lead to a contact etc.
-
Mitch Milam’s Microsoft Discussions » Blog Archive » Dynamics CRM 3.0 Customization: The basics September 28th, 2006 at 22:12
[...] I think the main decision point is whether or not you need multiple records. A multi-record solution would almost always require a secondary Entity that you link back to its parent. You can even do things like display that information within an iFrame on the data entry form so the user can see both the parent's information and the secondary information on the same screen. Note: It should be noted that some CRM 3.0 entities do not easily lend themselves to customization. Things like Quotes, Orders, etc. [...]
-
I found a unsupported solution for the problem of the Notes not showing when the entity is loaded in an iframe.
You will have to edit the '/_controls/notes/notectrl.htc' file.
In the 'notesAttachTabEvent' function, there's a line:
var oTabCtl = window.parent.document.getElementById("crmTabBar");
It gets the tabbar element, but because of the '.parent.' part, this tabbar element isn't found when loaded in an iframe. So you'll have to replace this line with the following code:
var oTabCtl = null;// Fix to show the 'Notes' of the iframed entity
if(parent.location != window.location)
{
// Used when the entity is iframed
oTabCtl = window.document.getElementById("crmTabBar");
}
else
{
// Normal load
oTabCtl = window.parent.document.getElementById("crmTabBar");
}
-
Simon Jackson April 21st, 2008 at 08:58
Thanks for the 'notesAttachTabEvent' fix, works great. Without this you get an error in CRM 4 that prompts the users to send an error report. While error reporting can be suppressed, this hack resolves the issue.
One thing to noe that the file has moved in CRM4 to '_static\_controls\notes\notectrl.htc'
Cheers
Leave a reply
-



