Displaying a Report in an IFrame of a CRM Entity Form

by Bill Owens 22. May 2008 18:41
Zahara Hirani published the following on his blog.
------------------------------
Recently Danny Varghese wrote a blog on displaying related entities in an IFrame of a CRM form. Let’s give it a little twist – Displaying a Report in an IFrame of a CRM Form.

For this example, we created a custom report that takes in the Account Id as a parameter and displays the campaign activities associated to that Account. Now let’s add the report to display on an account and show all campaign activities that have taken place with that account.

For this,

Open CRM and navigate to the Settings Module.
Now navigate to Customizations and select Customize Entities.
Select the Account entity for edit and navigate to the Forms and Views.
Select the Form for edit.
Add a Tab to the Account called ‘Campaign Activity’.
Add a section in that tab called ‘Campaign Activity Report’ and add an IFrame to the section.
For the URL of the IFrame, enter ‘about:blank’.
We will now add logic in the form OnLoad event that will create the report URL and append the Account Id for the report to use to display the campaign activities.

//Get Account Id and remove the {} from the start and end of the guid
var accountId = crmFormSubmit.crmFormSubmitId.value;
accountId = accountId.substring(1, accountId.length -1)

//Get Reporting URL
var url = 'http://localhost:5555/ReportServer?%2fCrowe+Chizek_MSCRM%
2fAccount+Campaign+Activity&rs:Command=Render&rs:Format=HTML4.0&
rc:Toolbar=false&rc:Parameters=false&AccountId=' + accountId;

document.getElementById('IFRAME_CampaignActivity').src = url;

In the above code you will notice, we had to remove the ‘{}’ from the account id the Form returns. The easiest way to get the report URL is to open the report using the report server.

For this,

Navigate to the reporting services report server (e.g. http://localhost/reportserver)
Now Navigate to the CRM Reports Folder. (e.g. Crowe_Chizek_MSCRM)
Now navigate to the custom report you created. (e.g. Account Campaign Report in our scenario).

Since we want the report in an IFrame, we do not want the report viewer toolbar and parameters to show. Hence the ‘rc:Toolbar=false&rc:Parameters=false”. Since we want the report to render in HTML 4.0, we can specify the format to render the report in by specifying ‘rs:Format=HTML4.0’. Last but not the least we add the Account Id to the querystring so that the report can pick up the Account Id from the querystring and use it to return only campaign activities associated to that account.

Now save and close the form and publish the entity.

Navigate to an account that has campaign activities and you should see the new tab and report render in the IFrame.

Tags: , , ,

CRM 4.0

Page List

About the author

I work for a consulting firm in Dublin Ohio called Affiliated Resource Group. For the last five years I have been spearheading our Microsoft Dynamics CRM practice. I have a deep appreciation for the Microsoft CRM platform and I am very excited about it. You might even describe me as a Microsoft CRM Advocate. I have many battle scars from my experience with the product and I’m constantly being asked questions about CRM and how-to-do something in it. Hence, this BLOG is to help disseminate that knowledge and information to everyone. As of last year I was posting links to many other blogs to help spread the knowledge, but now with the community.dynamics.com doing that for me, I will be following that practice unless a really juicy article catches my eye. Many people have asked where my post are for the first half of 2010, my company had me posting to another blog and maintain two was near impossible. I am now down to just this blog. So good luck and I hope that this blog may help in some way. If you have suggestions or questions, please email me them.

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 BillOnCRM