Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Paging is not working on RetrieveMultiple Message

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All,

I am working on Dynamics CRM project and in one requirement I am not able to find the solution. I have created plugin for RetrieveMultiple Message which fires on views which I have created for entity. But, somehow paging stopped working.  I am taking records information from OutputParameters like 

var retrievedResult = (EntityCollection)context.OutputParameters["BusinessEntityCollection"];

and query from 

QueryExpression qe = (QueryExpression)context.InputParameters["Query"];

I am looping on retrievedResult and modifying field values and added in different collection - EntityRecords. 

foreach (Entity entity in retrievedResult.Entities)
{

// My code 

-

-

EntityRecords.Entities.Add(entity);

}

Total number of records currently showing 272 but when i loop retrievedResult it only gives me record count which i have set in CRM (from option->general tab = 100)

At the end I am binding my collection to context.OutputParameters["BusinessEntityCollection"]  like

context.OutputParameters["BusinessEntityCollection"] = EntityRecords;

I want to implement paging and want to show all records with page size set by user. 

Please guide to implement paging in this scenario.

Thank you.

*This post is locked for comments

  • Suggested answer
    HarryLiu Profile Picture
    HarryLiu 5 on at
    RE: Paging is not working on RetrieveMultiple Message

    HI, Menroshan, How are you. please ask you .  how to resoved this issue?

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Paging is not working on RetrieveMultiple Message

    objQuery.PageInfo = new PagingInfo();

    objQuery.PageInfo.Count = queryCount;

    objQuery.PageInfo.PageNumber = pageNumber;

    objQuery.PageInfo.PagingCookie = null;

  • Suggested answer
    Zohaib Uddin Khan Profile Picture
    Zohaib Uddin Khan 2,811 on at
    RE: Paging is not working on RetrieveMultiple Message

    Hi,

    In order to implement the paging for the RetrieveMultiple, kindly check the below code (code snippet is from Page large result sets with QueryExpression):

    // Query using the paging cookie.
    // Define the paging attributes.
    // The number of records per page to retrieve.
    int queryCount = 3;
    
    // Initialize the page number.
    int pageNumber = 1;
    
    // Initialize the number of records.
    int recordCount = 0;
    
    // Define the condition expression for retrieving records.
    ConditionExpression pagecondition = new ConditionExpression();
    pagecondition.AttributeName = "parentaccountid";
    pagecondition.Operator = ConditionOperator.Equal;
    pagecondition.Values.Add(_parentAccountId);
    
    // Define the order expression to retrieve the records.
    OrderExpression order = new OrderExpression();
    order.AttributeName = "name";
    order.OrderType = OrderType.Ascending;
    
    // Create the query expression and add condition.
    QueryExpression pagequery = new QueryExpression();
    pagequery.EntityName = "account";
    pagequery.Criteria.AddCondition(pagecondition);
    pagequery.Orders.Add(order);
    pagequery.ColumnSet.AddColumns("name", "emailaddress1");                   
    
    // Assign the pageinfo properties to the query expression.
    pagequery.PageInfo = new PagingInfo();
    pagequery.PageInfo.Count = queryCount;
    pagequery.PageInfo.PageNumber = pageNumber;
    
    // The current paging cookie. When retrieving the first page, 
    // pagingCookie should be null.
    pagequery.PageInfo.PagingCookie = null;
    Console.WriteLine("Retrieving sample account records in pages...\n");
    Console.WriteLine("#\tAccount Name\t\tEmail Address"); 
    
    while (true)
    {
        // Retrieve the page.
        EntityCollection results = _serviceProxy.RetrieveMultiple(pagequery);
        if (results.Entities != null)
        {
            // Retrieve all records from the result set.
            foreach (Account acct in results.Entities)
            {
                Console.WriteLine("{0}.\t{1}\t{2}", ++recordCount, acct.Name,
                                   acct.EMailAddress1);
            }
        }
    
        // Check for more records, if it returns true.
        if (results.MoreRecords)
        {
            Console.WriteLine("\n****************\nPage number {0}\n****************", pagequery.PageInfo.PageNumber);
            Console.WriteLine("#\tAccount Name\t\tEmail Address");
    
            // Increment the page number to retrieve the next page.
            pagequery.PageInfo.PageNumber++;
    
            // Set the paging cookie to the paging cookie returned from current results.
            pagequery.PageInfo.PagingCookie = results.PagingCookie;
        }
        else
        {
            // If no more records are in the result nodes, exit the loop.
            break;
        }
    }


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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans