CRM 2011 Embed Report in IFrame and Pass Parameters from the Form

In CRM you can insert SubGrid and Chart. However this functionality is limited in a way that it can only grab the related entities that have direct relationship to that entity. If we want to get the other related entities from the related entity, it's not possible using the OOTB Subgrid and Chart.

In my case I want to display a chart in an Engagement Plan entity. This Engagement Plan is associated with an Account (N:1). The Account has 1:N relationships with Production History and Contract History entities that have information about commodity and tonnes produced. I want that chart to be shown on the Engagement Plan form. The parameters for this chart will be the Account Id and the Season Id located on the form.



The Steps:
  1. Create a custom SSRS Report to display this chart, taking @CRM_AccountId and @CRM_SeasonId as parameters.
  2. Insert an IFRAME on the form and give dummy Url. Also uncheck 'Restrict Cross Site Scripting' to allow cross scripting between servers.
  3. Create a javascript that is triggered in Form_OnLoad, Account_OnChange, and Season_OnChange:



The method for the form OnLoad is 'Form_onload'
The method for the field Onchange is 'loadChart'

Hope this helps,
Andreas

Comments

  1. Thanks for this post it helped me to load an ssrs report into an iframe on a form.

    ReplyDelete
  2. Andreas,

    In sample above, you are building the url for the report. The id= value is a specific guid. What is guid? Wouldn't it need to be dynamically set?

    var url = serverUrl + "/crmreports/viewer/viewer.aspx?action=filter&helpID=CommodityTonnes.rdl&id=%7bB135D3F7-65C1-E011-A653-005056A10003%7d";

    Todd

    ReplyDelete
    Replies
    1. Hi Todd,

      The guid is the Id of the report. You can find the id by opening the report record and hit F11 (then look in the address bar).

      P.S:
      You can also create a function to retrieve the id if you want (maybe by report name) using fetchXml. It's up to you :)

      Regards,
      Andreas

      Delete
  3. I have done all that but am using the filtered views and the reprot is asking for the user name and password. How do I get around that?

    ReplyDelete
    Replies
    1. Sorry I could not sign in for the post above but i have now subscribed to your blog so when you get a chance to answer this I will be notified. Many thanks Julie

      Delete
    2. Hi Julie,

      using filtered views in the report should be fine and is the normal way of creating reports. The issue must be related to a different cause.

      Are you able to open the report by going to the crm reportviewer url itself? i.e. "/crmreports/viewer/viewer.aspx?action=filter&helpID=..."

      Delete
  4. I noticed you used "p:[parameter]=[value]" in your url to pass a parameter into your report via url. I am looking for other commands to hide the toolbar and parameter pane.

    Where did you find out about "p:" and do you know where I can find the commands to hide the toolbar and parameter pane via URL?

    Thanks!

    ReplyDelete
    Replies
    1. Hey,

      Pretty sure I've read about the "p:" on the web as many people have been using this.

      Unfortunately the viewer.aspx doesn't support parameter to hide the toolbar. You might have to create custom aspx page for this one:

      http://social.microsoft.com/Forums/en-US/7bae9d87-f011-4d43-93db-980e2dca5caf/crmreportsviewervieweraspx-url-parameter-to-hide-toolbar-2011?forum=crmdevelopment

      Delete

Post a Comment

Popular posts from this blog

SharePoint 2013 anonymous access add attachments to list item

CRM Plugin - Parent and Child Pipeline

Sitecore custom publish agent from specific node and at a specific time