Maximum of 5000 responses from a FetchXml
Recently I was working with the Periodic Workflow Tool. I tried to run some workflows on an imported record set (about 26.000 records). This all seemed to work fine, but later we discovered that the workflows didn't run on all the records…
Soon I discovered that only the first 5000 records in the view were processed, after that it just stopped.
I checked the source code of the Periodic Workflow Tool, but I couldn't find a limit of 5000 anywhere and had to look further.
I came across this Microsoft article. In this article is explained that FetchXml works with paging and that it the maximum number of results can be adjusted.
My winning combination:
- Click Start, click Run, type regedit in the Open box, and then click OK.
- Locate and then select the following registry subkey:
HKEY_LOCAL_MACHINE\Software\Microsoft\MSCRM- On the Edit menu, point to New, and then click DWORD Value.
- Type TurnOffFetchThrottling, and then press ENTER.
- Right-click TurnOffFetchThrottling, and then click Modify.
- Type a number other than 0 in the Value data box, and then click OK.Note Step 6 lets you retrieve the number of records specified in the Count attribute of your fetch statement.
- On the File menu, click Exit.
Retrieve one or more fields using FetchXML
This function is used to retrieve multiple fields in MS CRM via fetchXml and return an array containing the requested values.
The function requires the following parameters:
- xml = fetchXml
- arrFields = array of attributes to return
When multiple records are found you can request the value of the attribute (example 1), recordcount (example 2) or the entire recordset (example 3). All these items are returned in an array whereby:
- array [0] = record count
- array [1] = array: to retrieve MULTIPLE records and multiple fields. The entire recordset (nodes) and fields (childnodes) are returned.
- array [2] = values: Use to retrieve ONE record and multiple fields. (NOTE: if multiple records are returned it will return the last !! )
Instructions:
To determine the exact fetchxml and fetchlayout follow this procedure:
- Use FetchXMLBuilder ( www,fetchxmlbuilder.codeplex.com) to build your fetchXML , or…
- Build query in Advanced Find and follow procedure below to get the fetchXML:
-
- Go to advanced find and press F11 to get the address bar.
- Create the query and layout
- In address bar paste this line of code:
javascript:void( new function(){ prompt("Fetch Parameters:",getFetchParams());function getFetchParams(){ return "FetchXml:\n" + advFind.FetchXml + "\n\n" + "LayoutXml:\n" + advFind.LayoutXml + "\n\n" + "EntityName:\n" + advFind.EntityName + "\n\n" + "DefaultAdvancedFindViewId:\n" + advFind.DefaultAdvancedFindViewId } } ) - Click Enter, all parameters are now in your clipboard and can be pasted in your code
Copy the code below in the OnLoad and see the examples below on how to call the function:
Display any FetchXML in an iFrame
This article describes how you can display any FetchXML in an iFrame in MS CRM. The idea is to create a complete request using the advanced find window and extract the FetchXml , LayoutXml and DefaultQueryId. For more information on how to display Fetch in an iFrame see the original post by Adi Katz: Display Fetch in IFRAME – Part 2.
Instructions:
To determine the exact fetchxml and fetchlayout follow this procedure(thanks to Ronald Lemmen):
1. Go to adv. find and press F11 to get the address bar.
2. Create the query and layout
3. In address bar paste this line of code:
javascript:void( new function(){ prompt("Fetch Parameters:",getFetchParams());function getFetchParams(){ return "FetchXml:\n" + advFind.FetchXml + "\n\n" + "LayoutXml:\n" + advFind.LayoutXml + "\n\n" + "EntityName:\n" + advFind.EntityName + "\n\n" + "DefaultAdvancedFindViewId:\n" + advFind.DefaultAdvancedFindViewId } } )
4. Click Enter, all parameters are now in your clipboard and can be pasted in your code.
5. Copy the code in the Onload event and call the function using one of the examples below: Read more

