Can not retrieve more than 5000 records RRS feed

  • Question

  • I have code that will retrieve a list of contacts since a certain modified on date.  This code works great for onpremise and hosted with one exception.

    With the CRM hosted version, I am only able to download 5000 records.  I use paging, so this should not be an issue (see code below)

    I have tried setting the page count to 1000, 2500, and 5000.  If I set it to 1000, then I get 5 pages, but on the 6th page I get an exception on the execute method.  Same goes for 2500, on the 3rd page (5001), I get an error.  So, for pagecount - 5000, the 2nd page gives an error.  This customer has 7500 active contacts, so I know that there are more contacts to get.

    I have read in forms about setting a registery, but that does not apply to hosted.  Also, the forums suggest using paging, which I am.

    I am stuck...help



    crmService = CrmLoginObj.GetCRMService(crmResponse)



    'Create the QueryExpression object.



    Dim query As QueryExpression = New QueryExpression()



    If (pageNum > 0) Then



    Dim page As PagingInfo = New PagingInfo()

    page.Count = 5000

    page.PageNumber = pageNum

    query.PageInfo = page



    End If



    'Set the properies of the QueryExpression object.

    query.EntityName = entityName.ToLower

    query.ColumnSet =


    New AllColumns()

    query.Criteria = filter



    'Create the request object.



    Dim retrieve As RetrieveMultipleRequest = New RetrieveMultipleRequest()



    'Set the properties of the request object.

    retrieve.Query = query

    crmService.Timeout = 600000

    crmService.Credentials = credentials



    'Execute the request.

    retrieved = crmService.Execute(retrieve)



    Catch ex As Exception






    Return Nothing



    End Try

    Wednesday, August 25, 2010 6:47 PM


All replies