Retrieve fixed number of records in FetchXML in Dynamics 365 CRM | [Quick Tip]

FetchXML is one of the common approaches used for retrieving records from CRM either using Plugins or JavaScript

At times, you want to retrieve only a fixed number of records based on the requirement or even if you want to just debug the plugin and don’t want all the records to be retrieved in your tests. So, here’s what you do!
Also, if you are new to Dynamics 365 CRM plugins, you might want to check this Plugin Development series I posted – Plugins Development in Dynamics 365 CRM for Beginners | [Blog Series]


  1. The FetchXML below is usually the only you are going to end up using since you are retrieving all the Contacts.

    This will retrieve all the records for you.

  2. Now, let’s add a “top” attribute in the <fetch> tag to retrieve only x number of records which you mention.

And that was it, same is applicable even if you are using XRMToolBox to test your FetchXML query using FetchXML tester.

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.