web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Filtering Subgrid to show only 5 records in crm2011

(0) ShareShare
ReportReport
Posted on by

Hi

I have a requirement to  show only last 5 cases on the contact form. Any advise would be great. Thanks

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Parvez Ghumra Profile Picture
    7 on at

    Hi Chaitanya,

    The following would be the simplest implementation:

    1. You will need to create a view on the Case entity to show the Case records with the appropriate columns and in the correct order.

    2. You will then need to place your subgrid on the Contact form, and in the designer, configure it such that it shows only a maximum of 5 rows. Notice that you'll still have the paging controls at the bottom of the subgrid allowing users to view more records

    Alternatively you could write a custom HTML control to display on your Contact form (or an SSRS report to run from your Contact records) and show only the 5 most recent associated Case records.

  • Royal King Profile Picture
    27,686 on at

    Create a view with sort order based on createdon date descending order. Set this view as default view on the subgrid with 5 rows. This will show 5 most recent cases always on top and remaining cases will be in next page.

  • Parvez Ghumra Profile Picture
    7 on at

    Apologies - I forgot to mention you need to configure your subgrid so it uses the new view you've created.

  • NKC Profile Picture
    on at

    i am aware of this but i don't want to show more than 5 . Thanks

  • Suggested answer
    Parvez Ghumra Profile Picture
    7 on at

    You could try tapping into the 'RetrieveMultiple' message in a plugin, check that the QuestionExpression object contains the columns you've specified in your view, and then modify the QueryExpression.TopCount property as you need?

  • Suggested answer
    Nuno Profile Picture
    2,005 on at

    Hi,

    As Parvez suggests you can register a plugin on retrievemultiple message (pre-operation) and check the query. If it matches to the filter of your view then limit the maximum number of records to be retrieved to five.

    guruprasadcrm.blogspot.pt/.../plugin-on-retrieve-multiple-message-in.html

    The following plugin (retrivemultiple message and pre-operation) code does that:

    if (context.InputParameters.Contains("Query") && context.InputParameters["Query"] is QueryExpression)
    {
            // set here the collums of the view to limit the records
            string[] viewCollums = { "title", "createdon" };
    
            // collumns of the query collumnSet
            QueryExpression query = context.InputParameters["Query"] as QueryExpression;
            string[] queryCollumns = query.ColumnSet.Columns.ToArray();
    
            // check if both arrays have the same elemts
            bool equals = viewCollums.Length == queryCollumns.Length && queryCollumns.All(x => viewCollums.Contains(x));
    
            // sets the number of rows to be returned.
            if (equals == true)
            {
               query.TopCount = 5;
            }
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans