Adding Activities to the Contact form in an iFrame
I came across the details on how to do this when reading a blog posting from Matt Wittemann a couple years back. I still use it and thought you might be interested. Another capability to demonstrate the flexibility of the configuration options of Microsoft Dynamics CRM Online.
1. Create an iFrame on the Contact form with the following properties.
2. Note the iFrame Name. The color coding will come in handy later. In this example I use IFRAME_Activities.
3. Install the Internet Explorer Developer Toolbar
4. Open a CRM contact record, copy the URL
5. Open a new IE window and enable the IE Developer toolbar
6. Paste the contact URL to load the Contact record with the IE dev toolbar enabled. Click on the toolbar icon for “Select Element by Click”
7. Find the Activities id by clicking on Activities from the left nav bar. Ensure to select the whole Activities area, not just the logo or the text. See outlined in blue in the screenshot below. Note the id: NavActivities from the middle window of the toolbar.
8. Click on the toolbar icon for “Select Element by Click” to disable it and click on Activities in the left nav bar to open the Contacts’ Activities list view in CRM. Enable the “Select Element by Click” functionality and click to the left of Filter On: Next 30 Days to select the windows highlighted in blue below.
9. Note the src value (areas.aspx?oId=…) from the middle window of the toolbar. In particular the part of the string after the CRM GUID starting at “&oType=2&security=…..”
10. Include the nav values and src value in the following script. The script is complete with values highlighted.
**********************************************************************************
//Render Activities in iFrame
if (crmForm.FormType != 1)
{
var navActivities;
navActivities = document.all.navActivities;
if (navActivities != null)
{
navActivities.style.display = "none";
document.all.IFRAME_Activities.src="areas.aspx?oId=" + crmForm.ObjectId +
"&oType=2&security=852023&tabSet=areaActivities";
}
else
{
alert("navActivities Not Found");
}
}
**********************************************************************************
11. Open the contact form to edit
12. Create a new tab called Address and move the current Address section to that tab
13. Create a new section on the General tab called Activities and show the divider. Add the IFRAME_Activities to the Activities section.
14. Add the previously edited jscript to the Contact form OnLoad event and Enable.
15. Publish your contact entity customizations.
16. Result will be the Contact form with Activities rendering in an iFrame on the form rather than appearing in the left nav bar.
Enjoy,
- Eric Boocock
Comments
Anonymous
August 19, 2008
Hi Eric, Adding activities, addresses or subaccounts to an iframe to any form in CRM 4.0 works only partially. Have you tried to "Add existing contact" or add a "New Address" whenever you have the forms inside an iframe? It does not work and returns a javascript error "could not complete the operation due to error 80020101"... Creating new activity or creating a new subaccount works, but whenever you try to "add existing" record, i.e. CRM does not just open an appropriate edit.aspx page, you will get the abovementioned error. Haven't you encoutered this error? You wrote that everything is working, so I would like to know whether you also got this error or you just didn't check it? Best regards, KubaAnonymous
August 19, 2008
Assuming you added the customization to the contact view as displayed above, did you save the contact record before trying to add the related records? If not this could be the cause of your error as the contact must be created before adding related records.Anonymous
December 12, 2008
The comment has been removedAnonymous
February 25, 2009
I've read and implemented this article on my development site and it appears to work but I cannot create any New Activities by press the New Activity button. Is the iFrame acting as a read-only conduit or should I be able to add new activities using it? ThanxAnonymous
February 26, 2009
"u101440" on the Iframe properties remove the check by "restrict cross-frame scripting", publish your changes and it will work.Anonymous
February 26, 2009
Thanx for this. Works excellent. One last thing though, there is a small amount of padding to either side and below the iFrame (you can see this in the pictures above as well). Is there a way to remove this?Anonymous
February 27, 2009
Thanks for your comments ddevine and u101440. I am unaware of any way to remove the padding in the iframe.Anonymous
March 10, 2009
Hello, I have a doubt. I have to connect with another DataBase to obtain some data. This DataBase is a Web Application, so I don't know if I have to insert an iFrame in the CRM with the url or create a Web Service, because I don't the differences. I want to know the advantages y disadvantages of these. I hope your help. Thanks.Anonymous
August 02, 2012
Any way to do this in 2011?Anonymous
August 03, 2012
@DavidWithers - you no longer need to use this blog to accomplish this. Grids were added as part of the CRM 2011 launch. Grids allow you to simply add related entities to CRM forms through the point and click form designer.Anonymous
November 08, 2012
@EricBoo - Partially true... Activity subgrids wont show activities of all related records, such as activies of child contacts --> you can vote this improvement as important at connect.microsoft.com/.../ability-for-sub-grid-activity-in-account-form-to-show-all-related-activities