CRM创建自定义视图

自定义视图的作用很多,最常用的就是给页面上的lookup字段进行筛选

Xrm.Page.getControl("fieldid").addPreSearch(function () {
        var filter = "<filter type='and'>"
        + "<condition attribute='xxx' operator='eq' value='" + xxx + "'/>"
        + "</filter>";
        Xrm.Page.getControl("fieldid").addCustomFilter(filter);
    });

但是在CustomFilter涉及到多个entity,需求很复杂的时候上面这种方式就有点力不从心了

那么还有一种原始的xml的方式可供使用,虽然复杂但是功能强大:

  1. 首先我们去系统高级查找页面创建要用的查找试图
    在这里插入图片描述

  2. 点击下载Fetch XML按钮就可以下载到xml格式的代码

  3. 在js代码中使用这个xml

var pFetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
                    + "<entity name='syzz_entity1'><attribute name='syzz_deliverynoteid'/>"
                    + "<attribute name='syzz_name'/><attribute name='createdon'/>"
                    + "<attribute name='syzz_orderid'/>"
                    + "<order attribute='createdon' descending='false'/>"
                    + "<filter type='and'>"
                    + "<condition attribute='syzz_site' operator='eq' value='" + currentBaseGuid + "' />"
                    + "</filter>"
                    + "<link-entity name='syzz_order' from='syzz_orderid' to='syzz_orderid' alias='aa'>"
                    + "<filter type='and'>"
                    + "<condition attribute='syzz_ordertype' operator='ne' value='2' />"
                    + "</filter>"
                    + "</link-entity>"
                    + "</entity>"
                    + "</fetch>"
//这里是布局代码可以套用
var pLayoutXml = "<grid name='resultset' object='10122' jump='syzz_entity1sn' select='1' icon='1' preview='1'>"
                    + "<row name='result' id='syzz_deliverynoteid'>"
                    + "<cell name='syzz_name' width='100'/><cell name='createdon' width='100'/>"
                    + "</row></grid>"
var id = "{CFD4B604-1C6A-4E61-B057-BA07620C0D46}";
Xrm.Page.getControl("syzz_delierynotedetail").addCustomView(id, "syzz_entity1", "我的自定义视图", pFetchXml, pLayoutXml, true);//最后一个bool参数用来设定是否将这个试图设置为默认试图
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值