Thursday, May 14, 2009

Record count per page For Microsoft Dynamics CRM 4.0

All you know that maximal records quanity is 250. I have wrote a little plugin which increases this count to 1000.

Idea of plugin - is to catch Execute message and change quantity of records per page.
Here the code of plugin:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Win32;
using System.Xml;
using Microsoft.Crm.SdkTypeProxy.Metadata;
using Microsoft.Crm.Sdk.Metadata;

namespace TestPlugin
public class RecordCounterExtender : IPlugin
public RecordCounterExtender(string config, string secureConfig)

#region IPlugin Members

public void Execute(IPluginExecutionContext context)
if (context.MessageName == "Execute" && context.InputParameters.Contains("FetchXml"))
XmlDocument indoc = new XmlDocument();

indoc.DocumentElement.Attributes["count"].Value = "1000";
context.InputParameters["FetchXml"] = indoc.OuterXml;



Here the result:

Step of plugin must be registered as a Pre Execute.


  1. Can you put up a screen shot of the Register New Step, or list the details. I'm not sure what to put for message

  2. If you could also mention the registration process along. I'm not sure where exactly to register the plugin.


  3. Hi. You can download pluginregistrator here -

    You have to make plugin's assembly strongnamed, buid and register it on CRM Server using pluginregistrator. Then you have to register a step - Message is Execute, Pre Event Stage, Synchronous, primary entity and child entity is none.

  4. Hello Adrij,
    Thank you for code. When I try to use Advanced find with this plugin, I recieve the following error message:
    NullReferenceException: Object reference not set to an instance of an object.]
    at Page1kRecordsPlugin.RecordCounterExtender.Execute(IPluginExecutionContext context)
    at Microsoft.Crm.Extensibility.PluginStep.Execute(PipelineExecutionContext context)
    How I can handle this situation? How I can analyze the Advanced Find on the input? Thank you.

  5. Hi, Roman.

    Check my new post issue you've found was fixed there.

  6. Hi, Roman. I am very appreciated for testing my solutions.

  7. Hi Andriy,

    Happy New Year 2011.
    Please provide some input with "how to set CRM IFD for CRM 2011 via ADFS?"


  8. Hi Jags.
    Thank you for the greetings. To get some "inputs" you should visit following forum -

  9. Do you have record counter for ms crm 2011

  10. Hello Mohita,
    Why do you need it for CRM 2011?