locked
FetchXml count is not working CRM 2011 RRS feed

  • Question

  • Hi Guys,

    i am trying to limit my fetch xml records to 5, by adding count as 5 as shown in below

    "<fetch mapping='logical' count='5' distinct='true' version='1.0'>" +

    But it is retrieving more than 5. I am wondering that why is it behaving weirdly.


    .I am doing it because, For few scenario i will have thousands of records where it is taking long time and crashing the page, If i limit it to 5 it may not take that much time.

    After i put count , It is still taking that much time.

    Any suggestion is appreciated

    Thanks,

    Sreeni


    Sreeni Pavalla


    Monday, January 20, 2014 10:20 PM

All replies

  • Hi Sreenivas, 

    Change your statement as

    "<fetch mapping='logical' page="1" count='5' distinct='true' version='1.0'>" +

    I hope it'll work.

    Thanks,

     E V Krishna

    Tuesday, January 21, 2014 4:40 AM
  • Hi,

    <

    fetch mapping="logical"count="50"aggregate="true"distinct="true"version="1.0">


    <entity name="lead">


    <attribute name="leadid"aggregate="count"alias="count"/>


    </entity>

    </fetch>

    I hope it'll work.

    Tuesday, January 21, 2014 5:09 AM
  • Krishna,

    Thank you for your response. It is returning 5 records when there is small amount of data. 

    For example , if i dont pass any filter condition and request for all records where i have 50k records, it is taking very long. But as per my understanding , it should just get 5 records with in no time right?

    Thank you,

    Sreeni Pavalla


    Sreeni Pavalla

    Tuesday, January 21, 2014 5:15 AM
  • Hi,

    No need to write "aggregate='count' alias='count' " this to all other attributes because it will gives you total records count of this fetch query.

    Tuesday, January 21, 2014 5:58 AM
  • hi akilesh,

    i am not looking for count. i want to retrieve just 100 records from 50k records.


    Sreeni Pavalla

    Tuesday, January 21, 2014 6:07 AM
  • hi,

    Select count from in stunware tool.

    Tuesday, January 21, 2014 6:19 AM
  • hi Sreeni,

    Your query is resolved or not.

    Tuesday, January 21, 2014 6:21 AM
  • Hi Akilesh,

    As i told you before i am not looking for count of the records, I want to retrieve the number of records. Lets say if my cleint asks me to show only 50, I should be able to pull 50, if 100, i should show 100.

    It works for me if i have less records. if i have more, it is taking time to pick just 100 records.

    Any help is appreciated.

    Thanks,
    Sreeni

    Sreeni Pavalla

    Tuesday, January 21, 2014 6:28 AM
  • Hi,

    For reducing the time you have select minimum fields because these records contains more data info, so query size has been increased. 

    Tuesday, January 21, 2014 6:38 AM
  • Neat piece of code and helpful to. . .But please make a bit change in it only the name of entity is in double quotes and everything else is in single quotes. Any way good effort from you guy.

    Tuesday, January 21, 2014 7:13 AM