zoukankan      html  css  js  c++  java
  • 微软crm mscrm 区域城市联动 用js+plugin实现

    ===onload======

    var lookupItem = new Array;
    lookupItem = crmForm.all.new_regionid.DataValue;
    if (lookupItem != null)
    {
        crmForm.all.new_regioncityid.additionalparams =  'id='+lookupItem[0].id;
    }
    else
    {
        crmForm.all.new_regioncityid.additionalparams =  'id={00000000-0000-0000-0000-000000000001}';
    }

    =======regionid   onchange========

    var lookupItem = new Array;
    lookupItem = crmForm.all.new_regionid.DataValue;
    if (lookupItem != null)
    {
        crmForm.all.new_regioncityid.additionalparams =  'id='+lookupItem[0].id;
    }
    else
    {
        crmForm.all.new_regioncityid.additionalparams =  'id={00000000-0000-0000-0000-000000000001}';
    }

    crmForm.all.new_regioncityid.DataValue=null;

     =======将下面代码做成Plug-In,并用注册工具注册到 execute 的message========

     public class PILookupFilter : IPlugin
        {
            #region IPlugin 成员

            public void Execute(IPluginExecutionContext context)
            {
                if (context.InputParameters.Contains("FetchXml"))
                {
                    string FetchXml = (String)context.InputParameters["FetchXml"];
                    string guid = HttpContext.Current.Request.QueryString["id"] == null ? null : HttpContext.Current.Request.QueryString["id"].ToString();

                    //throw new InvalidPluginExecutionException(FetchXml);

                    #region 根据区域Guid显示相应的区域城市
                    if (guid != null && FetchXml.Contains("<entity name=\"new_regioncity\">"))
                    {
                        if (new Guid(guid).Equals(new Guid()) == false)
                        {
                            string oldChar = "</entity>";
                            string newChar = "<link-entity name=\"new_region\" from=\"new_regionid\" to=\"new_regionid\" alias=\"aa\"><filter type=\"and\"><condition attribute=\"new_regionid\" operator=\"eq\" uitype=\"new_region\" value=\"" + guid + "\"/></filter></link-entity></entity>";

                            //throw new InvalidPluginExecutionException(FetchXml.Replace(oldChar, newChar));

                            context.InputParameters["FetchXml"] = FetchXml.Replace(oldChar, newChar);
                        }
                    }
                    #endregion                         
            }

            #endregion

    }

  • 相关阅读:
    吴裕雄--天生自然 PHP开发学习:数组
    吴裕雄--天生自然 JAVASCRIPT开发学习:测试 jQuery
    【t065】最敏捷的机器人
    【t079】火星上的加法运算
    【t053】整数去位
    【9604】纪念品分组
    【心情】bjdldrz
    【9601】零件分组
    【9916】编辑距离
    【38.24%】【POJ 1201】Intervals
  • 原文地址:https://www.cnblogs.com/seerlin/p/1869102.html
Copyright © 2011-2022 走看看