Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Processing more than 5000 records using CRM SDK

Posted on by 115

Hi guys, 

I want to update around 7000 records using CRM SDK. I have tried this paging method, but still getting only 5000 records updated. 

int success = 0;
            int failed = 0;
            int recordCount = 0;
            int recordProcessing = 1;
            int pageNumberAmpli =1 ;
            
            QueryExpression query_amplifier = new QueryExpression("lnkt_amplifiercode");
            query_amplifier.Criteria = new FilterExpression();
            query_amplifier.ColumnSet = new ColumnSet(true);
            //query_amplifier.Criteria.AddCondition("lnkt_itcode", ConditionOperator.Equal, "BKB8291000");
            query_amplifier.PageInfo = new PagingInfo();
            query_amplifier.PageInfo.Count = 5000;
            query_amplifier.PageInfo.PageNumber = pageNumberAmpli;
            query_amplifier.PageInfo.PagingCookie = null;
            query_amplifier.PageInfo.ReturnTotalRecordCount = true;
            query_amplifier.Criteria.AddCondition("modifiedon", ConditionOperator.LastXMonths, 4);
            //OrderExpression order = new OrderExpression();
            //order.AttributeName = "lnkt_name";
            //order.OrderType = OrderType.Ascending;

            EntityCollection amplifier_colect = new EntityCollection();

            amplifier_colect = service.RetrieveMultiple(query_amplifier);
           

            do
            {
                //UPDATE SCRIPTS
            }   
            while (amplifier_colect.MoreRecords);
            {
                Console.WriteLine("\n****************\nPage number {0}\n****************", query_amplifier.PageInfo.PageNumber);
                Console.WriteLine("#\tMigrating Amplifier");
                Console.WriteLine("Total Records Processing Per Batch: "   recordProcessing);
                Console.WriteLine("Number of Success: "   success);
                Console.WriteLine("Number of Failed : "   failed);
                query_amplifier.PageInfo.PageNumber  =1;
                query_amplifier.PageInfo.PagingCookie = amplifier_colect.PagingCookie;

                recordProcessing = 0;
                success = 0;
                failed = 0;

            }

Can you help me if there any mistake within my code ?

  • Suggested answer
    Nishant Rana Profile Picture
    Nishant Rana 55 Microsoft Employee on at
    RE: Processing more than 5000 records using CRM SDK

    This should help

    nishantrana.me/.../

  • Suggested answer
    Johao Larios Profile Picture
    Johao Larios 1,795 on at
    RE: Processing more than 5000 records using CRM SDK

    Hello there,

    have you already tried with execute multiple?

    docs.microsoft.com/.../use-executemultiple-improve-performance-bulk-data-load

    docs.microsoft.com/.../api-limits

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Processing more than 5000 records using CRM SDK

    Hello,

    Place

    amplifier_colect = service.RetrieveMultiple(query_amplifier);

    to

    "do" loop.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans