Quantcast
Channel: reports – Dynamics CRM Tip Of The Day
Viewing all articles
Browse latest Browse all 8

Tip #43: Embed a pre-filtered report in an iFrame

$
0
0

One of the benefits of the Microsoft Dynamics CRM SSRS pre-filtering capabilities is that you can run a report in context of a record, such as an account, so when you run the report, it just shows data related to that record. Reports can also be embedded in forms with iFrames, and prefiltering is very handy to make the embedded report reflect just the record you are viewing on the form.

    1. Add an iframe to your form in which to display the report. In this example I called it “IFRAME_Report.” Set the URL for the iFrame to about:blank and uncheck the “Restrict cross frame script” checkbox.
    2. Run the prefiltered report from the report menu or the form “run report” button. If you see the filter screen, filter the report to the desired record.
    3. After the report runs, copy the URL in your browser. If the URL bar is not displayed, click CTRL+N.
    4. Replace the highlighted lines in the following function to match your report URL. Note–you don’t want the website domain part of the URL–the /crmreports/viewer… URL makes it dynamic, so the report should work in any environment, as well as offline.
    5. Call the showReport function in the OnLoad event.
function showReport()
{
   //Get iframe
   var iframeObject = Xrm.Page.getControl("IFRAME_Report");

   if (iframeObject != null) {
      var strURL = "/crmreports/viewer/viewer.aspx"
         + "?action=run&context=records&helpID="
         + "Name%20of%20Report"
         + ".rdl&id=%7b"
         + "33db4d7f-446e-e311-940f-005056ab530d"
         + "%7d&records="
         + Xrm.Page.data.entity.getId()
         + "&recordstype=1";

      //Set URL of iframe
      iframeObject.setSrc(strURL);
   }
}
Tweet about this on TwitterShare on FacebookShare on Google+

Viewing all articles
Browse latest Browse all 8

Trending Articles