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.LoadXml((string)context.InputParameters["FetchXml"]);

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

#endregion

}
}



Here the result:



Step of plugin must be registered as a Pre Execute.

11 comments:

  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

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

    Thanks.

    ReplyDelete
  3. Hi. You can download pluginregistrator here - http://www.axforum.info/forums/attachment.php?attachmentid=4623&d=1241709390.

    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.

    ReplyDelete
  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.

    ReplyDelete
  5. Hi, Roman.

    Check my new post http://a33ik.blogspot.com/2009/09/overriding-records-per-page-count-for.html issue you've found was fixed there.

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

    ReplyDelete
  7. Hi Andriy,

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

    Thanks,
    Jags

    ReplyDelete
  8. Hi Jags.
    Thank you for the greetings. To get some "inputs" you should visit following forum - http://social.microsoft.com/Forums/en-US/crm2011beta/threads

    ReplyDelete
  9. Do you have record counter for ms crm 2011

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

    ReplyDelete