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

    }

  • 相关阅读:
    分布式_理论_03_2PC
    分布式_理论_02_Base 理论
    分布式_理论_01_CAP定理
    分布式_理论_00_资源帖
    Git_学习_09_指定某些文件不上传
    Java_脚本引擎_03_nashorn支持es6
    Idea_学习_10_Idea远程debug
    Mybatis_总结_06_用_插件开发
    Mybatis_总结_05_用_Java API
    【BZOJ】2212: [Poi2011]Tree Rotations
  • 原文地址:https://www.cnblogs.com/seerlin/p/1869102.html
Copyright © 2011-2022 走看看