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

    }

  • 相关阅读:
    vue项目中关于axios的简单使用
    日常开发中的几个常用跨域处理方式
    duilib踩坑记录
    unicode utf8 学习记录
    __metaclass__ 实现单列模式
    深入理解Python中的元类(metaclass)
    python 获取本机 IP
    百度定位api 定位不准修正
    iptables
    timeshift 安装使用说明
  • 原文地址:https://www.cnblogs.com/seerlin/p/1869102.html
Copyright © 2011-2022 走看看