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

    }

  • 相关阅读:
    IMail不能发送邮件的解决方法
    asp.net防止刷新重新提交触发后台事件的方法
    你的网站被“白名单”了吗?
    网站权限引起的504错误的问题
    asp.net Web Service请求因 HTTP 状态 400 失败: Bad Request的原因
    对现有数据库的表做分区的方法
    测试 Cookie在不同浏览器内容长度限制的测试
    Thinkphp框架中使用memcache缓存的方法
    替换手机号中间数字为*号或隐藏IP最后位
    linux mysql 操作命令
  • 原文地址:https://www.cnblogs.com/seerlin/p/1869102.html
Copyright © 2011-2022 走看看