Tuesday 20 March 2012

Microsoft Dynamics CRM 2011 - Form Sub-Grids


Microsoft Dynamics CRM 2011 has many new features which made it easier to customize and enhance the product. I reckon this new version, Dynamics CRM 2011, catapulted the product into another league. I am sure Microsoft Dynamics CRM 2011 will steal the limelight from all its competitors to prove itself as number one.

One of the new features in Dynamics CRM 2011 is sub-grids. The sub-grids can be inserted in entity forms to display the related data. For example, I can have a sub-grid in "Account" entity form to display all the related "Opportunities". In the same way in "Account" form I can have sub-grids to display related "Orders" or related "Quotes" or related "Invoices". The uses of sub-grids make it so easy to attach related entity records.

In Microsoft Dynamics CRM 4.0 the same functionality is achieved by displaying the related entity records within IFrames. In Microsoft Dynamics CRM 2011 we have out of the box sub-grids feature which is simple to configure and use.

In this blog I will show how to insert a sub-grid and display related records.

1) Below is the list of custom entities in my CRM 2011. I will use two of them in my blog to demo this sub-grid feature. These entities are "Genres" and "Sub Genres".

I have an entity called "Movies". This entity contains the records of movies. These movies are categorised by genre and sub genre. Every movie falls under a genre and a sub genre.

Every sub genre has a parent genre. There is a 1:N relationship between genre and sub genre. In my demo genre record will display related sub genres in a sub-grid.

Genres and Sub Genres

2) Below is the list of all active genre records.

Genre Records

3) Below is the list of all active sub genre records. As seen and marked below, each sub genre has a related genre. In other words every genre has multiple related sub genres.

Sub Genre Records

4) I will customize the "Genre" entity form to add a sub-grid. To do this I will go to genres and click on "Customize Entity" button.

Customize the "Genre" Entity Form

5) This will open the genre form in edit or design mode. Highlight the section where you want to add the sub-grid. As I want the sub grid in "General" tab and after "Genre" section, so I will select the "General" tab. I will click on "Sub-Grid" button on the "Insert" ribbon. This will open a "List or Chart Properties" window.

Add a Sub-Grid to "Genre" Entity Form

6) I will fill in the required details in the "List or Chart Properties" window. This will set the properties for the sub-grid.

I will give it a unique name of "SubGenre". I will give it a label of "Sub Genres".

The important section which configures the sub-grid's display can be set in "Data Source". Select "Only Related Records" for Records. This will only show related records for the genre record. In the "Entity" field select the option "Sub Genres (Movie Genre)". This is what gets displayed in the sub-grid. Since we have selected the option of "Sub Genres (Movie Genre)", which means sub-grid will only display sub genres for the genre record.

Sub-Grid Properties

7) Below are the final settings for "Data Source" section in "List or Chart Properties" window. Click "OK" button.

Sub-Grid's Data Source Settings

8) The sub-grid is inserted in my genre form. It is inserted in the "General" tab. Now I save my changes and test the output.

Sub-Grid Added to "Genre" Entity Form

9) I will save and publish my changes so that I can view the sub-grid on the genre form. 

Save and Publish the "Genre" Entity Form

10) I will test this sub-grid feature. I will go to the genres and open the first genre "Family". As seen below the sub-grid in "Family" genre form shows all the sub genres. These sub genres are the ones which are related to the genre "Family".

Genre "Family" and its Sub-Grid showing related Sub Genres

I will close the "Family" genre record and open the "Non Mainstream" genre record. As seen below the sub-grid in "Non Mainstream" genre form will display only sub genres related to it.

Genre "Non Mainstream" and its Sub-Grid showing related Sub Genres

As seen in my blog, I have added the sub-grid functionality without doing major work. In CRM 2011 this feature is out of the box. The same functionality was achieved through IFrames and JavaScript in CRM 4.0.  

I hope this blog about 'Microsoft Dynamics CRM 2011 - Form Sub-Grids' was informative. Please feel free to leave your comments.

3 comments:

  1. Thanks for publishing this article. It is very informative.

    We had used iFrames all over in our project with CRM 4.0.

    IFrames are not dead though. We still can use them for non related entity info etc. Would you please, if you know of any, article that explains where iframe still can be a good candidate in CRM 2011.
    Thanks : Andy

    ReplyDelete
  2. Hi Andy,

    In CRM 4.0 IFrames was the only way of displaying associated records. This has changed in CRM 2011 with sub-grids. Sub-Grids allow you to separately choose a filter to "view only related records", in combination with any of the system views available for the entity in question.

    IFrames still can be used for displaying web pages. If you are using external website's web pages, you can use IFrames.

    MSCRM has a rich text editor as well that is also hosted in IFrame. e.g. for showing a long message say 1000 chars long on CRM form no other control can do it.

    I hope this helps,
    Ashish

    ReplyDelete
  3. How many subgrid are created in the single form/single record - CRM 2011/2013?

    ReplyDelete