web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Fetch XML with limits

(0) ShareShare
ReportReport
Posted on by 94

Hi, 

Iwant to get the X (number) last (top) result querry and the Y (number) of old result querry  using fetch XML in dynamics .

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Fetch XML with limits

    Hi ,

    Could you please try to write fetchxml using top -

    <fetch top="5" >
      <entity name="contact" >
        <attribute name="contactid" />
        <attribute name="fullname" />
      </entity>
    </fetch>


  • feninzie Profile Picture
    94 on at
    RE: Fetch XML with limits

    I try it with addCustomView but I didn't get the true number of count in fetch XML despite I get all the true results but I want to get only N records

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Fetch XML with limits

    Hi,

    You can get last Top result using top or count.

    Example

    <fetch mapping='logical' count='3'>

      <entity name='account'>

         <attribute name='name' alias='name'/>

      </entity>

    </fetch>

    To fetch old result you can use createdon field sort it with desc.

    Hope it helps

    Thanks

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Fetch XML with limits

    Hi,

    Here is the reference you may get help for addCustomView  , you just need to add the fetch XML.

    community.dynamics.com/.../223342

    And for addCustomFilter  is only for condition you can not add count here .

  • feninzie Profile Picture
    94 on at
    RE: Fetch XML with limits

    Hi ,what's the method that I can use in the script because I tried  in javascript with addCustomView  and addCustomFilter but I didn't get any results in the lookup that I want is to get the last three results of this fetch in the lookup .

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Fetch XML with limits

    Hi,

    Not sure is it requirement or not , bit confused your question . Do you want to retrieve number of record based on creation date?

    //For Newest Record top 10
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" count="10"> <entity name="account"> <attribute name="name" /> <attribute name="primarycontactid" /> <attribute name="telephone1" /> <attribute name="accountid" /> <attribute name="createdon" /> <order attribute="createdon" descending="false" /> </entity> </fetch> //For Older record top 10 <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" count="10"> <entity name="account"> <attribute name="name" /> <attribute name="primarycontactid" /> <attribute name="telephone1" /> <attribute name="accountid" /> <attribute name="createdon" /> <order attribute="createdon" descending="true" /> </entity> </fetch>


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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans