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

Notifications

Announcements

No record found.

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

    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>


  • feninzie Profile Picture
    94 on at

    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

    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 .

  • Suggested answer
    Community Member Profile Picture
    on at

    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

  • feninzie Profile Picture
    94 on at

    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
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Could you please try to write fetchxml using top -

    <fetch top="5" >
      <entity name="contact" >
        <attribute name="contactid" />
        <attribute name="fullname" />
      </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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans