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
Hi ,
Could you please try to write fetchxml using top -
<fetch top="5" > <entity name="contact" > <attribute name="contactid" /> <attribute name="fullname" /> </entity> </fetch>
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
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
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 .
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 .
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
HR-09070029-0 2
Aric Levin - MVP 2 Moderator
ED-30091530-0 1