22 Sep
Posted by: mitch in: Customization, Dynamics CRM
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
6 Responses
Bas van Sluis
22|Sep|2006 1Hello 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
mitch
22|Sep|2006 2Bas,
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
23|Sep|2006 3Hi 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
28|Sep|2006 4[…] 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. […]
Maarten Docter
30|Oct|2007 5I 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
21|Apr|2008 6Thanks 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
Search
Categories
Archives
Meta
Most Viewed
Tags
A design creation of Design Disease
Copyright © 2007 - Mitch Milam's Microsoft Discussions - is proudly powered by WordPress
InSense 1.0 Theme by Design Disease brought to you by HostGator Web Hosting.