微软CRM记录列表每页显示记录数量只能在25、50、75、100、250中选择一个,有时候经常有需求需要在一页上显示超过250个记录,以便执行某些批量操作功能,比如批量删除、编辑、运行工作流等等;

通过Plugin可以实现微软CRM记录列表每页显示超过250个记录,代码如下:

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


namespace RecordCounterExtender
{
    public class RecordCounterExtender:IPlugin
    {
        public void Execute(IPluginExecutionContext context)
        {
            if (context.MessageName == "Execute" && context.InputParameters.Contains("FetchXml"))
            {
                XmlDocument indoc = new XmlDocument();
                indoc.LoadXml((string)context.InputParameters["FetchXml"]);

                if (indoc.DocumentElement.Attributes["count"] != null)
                {
                    indoc.DocumentElement.Attributes["count"].Value = "1000"; //一页显示1000个记录
                    context.InputParameters["FetchXml"] = indoc.OuterXml;
                }
            }
        }
    }
}

Plugin注册方法:

posted on 2010-08-24 15:35  Batistuta Cai  阅读(1668)  评论(0编辑  收藏  举报