locked
how to use select top 10 record in crm 4.0? RRS feed

  • Question

  • how to use select top 10 record in crm 4.0?

    using web service

    i am using filter expression & ConditionExpression

    so how to use top 10 record i want code snippets 

    Thanks in Advance

    Tuesday, August 16, 2011 8:44 AM

Answers

  • Hi Krunal,

     

    You can use QueryByAttribute.PageInfo property to retrieve 10 records, and don't look for more pages.

     

     

    //Create the QueryExpression object.

    QueryExpression query = new QueryExpression(); 

    //The query returns 1 page and 10 record entity instance per page.

    query.PageInfo = new PagingInfo();

    query.PageInfo.Count = 10;

    query.PageInfo.PageNumber = 1

     


    Thomas T(MCBMSS) If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Thomas Thankachan Tuesday, August 16, 2011 9:22 AM
    • Marked as answer by krunal89 Tuesday, August 16, 2011 11:09 AM
    Tuesday, August 16, 2011 9:21 AM

All replies

  • hi any body is ther please help its urgent
    Tuesday, August 16, 2011 9:14 AM
  • Tuesday, August 16, 2011 9:19 AM
    Moderator
  • Hi Krunal,

     

    You can use QueryByAttribute.PageInfo property to retrieve 10 records, and don't look for more pages.

     

     

    //Create the QueryExpression object.

    QueryExpression query = new QueryExpression(); 

    //The query returns 1 page and 10 record entity instance per page.

    query.PageInfo = new PagingInfo();

    query.PageInfo.Count = 10;

    query.PageInfo.PageNumber = 1

     


    Thomas T(MCBMSS) If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Thomas Thankachan Tuesday, August 16, 2011 9:22 AM
    • Marked as answer by krunal89 Tuesday, August 16, 2011 11:09 AM
    Tuesday, August 16, 2011 9:21 AM
  • Hi Krunal,

    you can use fetchxml to fetch top 10 records

    here is example from SDK

    <fetch mapping='logical' page='1' count='10'>
      <entity name='account'>
       <all-attributes />
       <link-entity name='systemuser' to='createdby'>
          <filter type='and'>
             <condition attribute='firstname' 
                   operator='eq' value='Jeff' />
             <condition attribute='lastname' 
                   operator='eq' value='Smith' />
          </filter>
       </link-entity>
       <filter type='and'>
          <condition attribute='createdon' operator='last-month' />
       </filter>
      </entity>
    </fetch>
    


    Mahain : MS CRM Freelancer
    Tuesday, August 16, 2011 9:24 AM
    Moderator
  • thanks for your instant reply Thomas T(MCBMSS)

    //Create the QueryExpression object.

    QueryExpression query = new QueryExpression(); 

    //The query returns 1 page and 10 record entity instance per page.

    query.PageInfo = new PagingInfo();

    query.PageInfo.Count = 100;

    query.PageInfo.PageNumber = 1

    Can I modify the Count to my requirement say 100 or 1000 or how much max?????

    if yes then please provide me the code snippest

    Thannks again



    Tuesday, August 16, 2011 10:25 AM