• Dynamics CRM2013 Lookup Filtering using addCustomFilter


    dynamics crm中对lookup视图的过滤是一个很平常性的需求,在2011的时候都是用添加自定义视图的方式例如下面这段示例代码

    <span style="font-size: 18px;">var pEntityName = "sc_stock";
        var pViewDisplayName = "符合条件库存";
        var </span><span style="font-size:18px;">pSotckControl</span><span style="font-size: 18px;">= Xrm.Page.getControl("new_stock");
         
        var pFetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
                        + "<entity name='sc_stock'><attribute name='sc_stockid'/>"
                        + "<attribute name='sc_stocksn'/><attribute name='createdon'/>"
                        + "<attribute name='sc_salebillamount'/><attribute name='sc_outputamount'/>"
                        + "<attribute name='sc_bizbookresidue'/><attribute name='sc_bizbookamount'/>"
                        + "<attribute name='sc_owner'/><attribute name='sc_storage'/>"
                        + "<attribute name='sc_stocktype'/>"
                        + "<attribute name='sc_uom'/>"
                        + "<attribute name='sc_tank'/>"
                        + "<attribute name='sc_product'/>"
                        + "<attribute name='sc_bizunit'/>"
                        + "<attribute name='sc_bizoperator'/>"
                        + "<attribute name='sc_purchase'/>"
                        + "<order attribute='sc_stocksn' descending='false'/>"
                        + "<filter type='and'>"
                        + "<condition attribute='sc_decreaseandoverflow' operator='eq' value='" + this.sc_isDecreaseandoverflow + "'/>"                    
                        + "</filter>"
                        + "</entity>"
                        + "</fetch>"
    
         var pLayoutXml = "<grid name='resultset' object='10122' jump='sc_stocksn' select='1' icon='1' preview='1'>"
                            + "<row name='result' id='sc_stockid'>"
                            + "<cell name='sc_stocksn' width='100'/><cell name='sc_purchase' width='100'/>"
                            + "<cell name='sc_bizunit' width='100'/><cell name='sc_bizoperator' width='100'/>"
                            + "<cell name='sc_product' width='100'/><cell name='sc_owner' width='100'/>"
                            + "<cell name='sc_storage' width='100'/><cell name='sc_tank' width='100'/>"
                            + "<cell name='sc_stocktype' width='100'/><cell name='sc_uom' width='100'/>"
                            + "<cell name='sc_bizbookamount' width='100'/><cell name='sc_bizbookresidue' width='100'/>"
                            + "<cell name='sc_outputamount' width='100'/><cell name='sc_salebillamount' width='100'/>"
                            + "<cell name='createdon' width='125'/>"
                            + "</row></grid>"
         var id = "{CFD4B604-1C6A-4E61-B057-BA07620C0D46}";         
         pSotckControl.addCustomView(id, pEntityName, pViewDisplayName, pFetchXml, pLayoutXml, false);
         pSotckControl.setDefaultView(id);</span>
    要写一大堆的查询XML,显示XML很是繁琐

    2013中加入了addCustomFilter这个API,

    <span style="font-size:18px;">Xrm.Page.getControl("new_stock").addPreSearch(function () {
            var filter = "<filter type='and'>"
            + "<condition attribute='sc_decreaseandoverflow' operator='eq' value='" + this.sc_isDecreaseandoverflow + "'/>"
            + "</filter>";
            Xrm.Page.getControl("new_stock").addCustomFilter(filter);
        });</span>
    代码极度简化,XML也只是用到了一个condition条件而已,只是对默认的视图添加了搜索过滤而不是添加新的自定义视图。

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    ORACLE 定时执行存储过程
    Java 基于spring 暴露接口 供外部调用
    java 从jsp页面传集合给controller
    Java 后台验证的工具类
    Xcode12真机/模拟器运行项目非常慢的解决方式
    苹果手机系列 安全区高度/设置粗体高度不正常
    Xcode 官方下载地址
    OC UICollectionView 滚动完全显示item
    cocospod 更新到指定版本及其问题
    OC 一张图片填充满整个导航栏(包含X系列)
  • 原文地址:https://www.cnblogs.com/VicTang/p/4799578.html
Copyright © 2020-2023  润新知