实现方式参考官方文档提供的Xrm.Page.getControl(arg).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, isDefault)
参数的解释:
viewId:具体的视图id 可通过视图编辑器窗体上方的网址中复制
entityName:实体名
viewDisplayName:视图名称,可自己编写一个名称
fetchXml:过滤查询用的具体fetchXml语句,类似于编写sql,可以通过在线sql转fetchxml工具转换( http://www.sql2fetchxml.com/
layoutXml:定义视图布局的 XML,格式比较固定,以一个比较简单的为例:
layoutXml = '<grid name="resultset" object="10057" jump="foton_sequenceno" select="1" icon="1" preview="1"><row name="result" id="foton_receiptid"><cell name="foton_sequenceno" width="150" /><cell name="createdon" width="150" /></row></grid>';
注意:xml的连接符号如:'<''>'不要有空格
<grid>中name可固定为resultset,也可以定义成实体名
object为对应实体的ObjectTypeCode,数据库查询或者实体浏览器中查看
select用0或1都可以 0和1对应是否可以在视图中进行查询
icon和preview固定1
<row>中的name固定result即可,id为对应的实体主键
<cell>为具体要显示的列配置,name为字段名,width为显示的宽度
isDefault:视图是否应该是默认视图 默认设置为true即可
 
项目中的使用示例:
1.给字段添加onchange事件
 1 /**
2 * 选择产品代码后,根据产品资源与包装方式的关系过滤包装方式可选择的数据,添加自定义过滤视图
3 * @param {any} productFourthId 产品代码数据id
4 */
5 function addPostingLookupFilterCustomView(productFourthId) {
6 if (productFourthId == null) {
7 return
8 }
9 let fetchXml = '<fetch version="1.0" mapping="logical"><entity name="new_way_of_packaging"><attribute name="new_way_of_packagingid" /><attribute name="new_name" /><attribute name="new_cost" /><attribute name="createdon" /><link-entity name="new_product_packaging_relationship" from="new_way_of_packagingid" to="new_way_of_packagingid" alias="ship" link-type="inner"><filter type="and"><condition attribute="new_product_fourthid" operator="eq" value="' + commonUtil.delBrackets(productFourthId) + '" /></filter></link-entity></entity></fetch>';
10 let layoutXml = '<grid name="" object="10047" jump="new_name" select="1" icon="1" preview="0"><row name="new_way_of_packaging" id="new_way_of_packagingid"><cell name="new_name" width="300" /><cell name="new_cost" width="200" /><cell name="createdon" width="150" /></row></grid>';
11 Xrm.Page.getControl("new_way_of_packaging").addCustomView("{DB40ABE7-FB8D-4E41-ACF8-7569ECEAB149}", "new_way_of_packaging", "包装方式过滤产品资源查询", fetchXml, layoutXml, true);
12 }
2.在页面加载时做判断显示视图 结合查找字段addPreSearch的方法
 1 //窗体onload函数汇总调用方法
2
3 /**
4 *过滤源、目标经销商来款可选视图
5 * @param {any} type 1转出账户 2转入账户
6 */
7 function preAccountToParagraphFilterLookup(type) {
8 if (!type) {
9 return
10 }
11 if (type == 1) {
12 Xrm.Page.getControl("new_lkaccount").addPreSearch(function () {
13 addPostingLookupFilterCustomView(type)
14 })
15 } else {
16 Xrm.Page.getControl("new_targetlkaccount").addPreSearch(function () {
17 addPostingLookupFilterCustomView(type)
18 })
19 }
20 }
21 /**
22 * 添加过滤源、目标经销商来款可选择的自定义视图
23 * @param {any} type 1转出账户 2转入账户
24 */
25 function addPostingLookupFilterCustomView(type) {
27 var fetchXml = '';
28 let amountId = null
29 if (type == 1) {
30 amountId = Xrm.Page.getAttribute("new_amountid_from").getValue()
31 amountId = amountId ? amountId[0].id : null
32 if (amountId == null) {
33 return
34 }
35 } else {
36 amountId = Xrm.Page.getAttribute("new_amountid_to").getValue()
37 amountId = amountId ? amountId[0].id : null
38 if (amountId == null) {
39 return
40 }
41 }
42 fetchXml = '<fetch version="1.0" mapping="logical"><entity name="new_lkaccount"><attribute name="new_lkaccountid" /><attribute name="new_name" /><attribute name="createdon" /><filter type="and"><condition attribute="new_approvalstatus" operator="eq" value="40" /><filter type="or"><condition attribute="new_amountid_capital" operator="eq" value="' + commonUtil.delBrackets(amountId) + '" /><condition attribute="new_amountid_parts" operator="eq" value="' + commonUtil.delBrackets(amountId) + '" /></filter></filter></entity></fetch>';
43 var layoutXml = '<grid name="" object="10174" jump="new_name" select="1" icon="1" preview="0"><row name="new_lkaccount" id="new_lkaccountid"><cell name="new_name" width="300" /><cell name="createdon" width="150" /></row></grid>';
44
45 if (type == 1) {
46 Xrm.Page.getControl("new_lkaccount").addCustomView("{4F08B504-491C-473F-B215-FF99894870D9}", "new_lkaccount", "经销商来款过滤资金账户查询", fetchXml, layoutXml, true);
47 } else {
48 Xrm.Page.getControl("new_targetlkaccount").addCustomView("{4F08B504-491C-473F-B215-FF99894870D9}", "new_lkaccount", "经销商来款过滤资金账户查询", fetchXml, layoutXml, true);
49 }
50 }
 

Dynaimc CRM查找字段自定义过滤视图的更多相关文章

  1. Dynamics CRM 查找字段下拉的最多10个选项的排序规则

    原文链接来自DTCCh论坛http://dynamics.ms-talent.com.cn/bbs/content/?id=1406&catogory=CRM 如果你是从事dynamics c ...

  2. Office365学习笔记—Xslt自定义列表视图

    1,在Office365中需要添加自定义的视图!用Spd添加视图,这儿我添加一个testView! (1)打开testView.aspx将</ZoneTemplate>节点中的内容全部删除 ...

  3. 查找字段的筛选-使用addCustomView

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复231或者20161031可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...

  4. MS CRM 2011的自定义和开发(11)——插件(plugin)开发(二)

    http://www.cnblogs.com/StoneGarden/archive/2012/02/06/2339490.html MS CRM 2011的自定义和开发(11)——插件(plugin ...

  5. 自定义View视图

    自定义View视图文件查找逻辑 之前MVC5和之前的版本中,我们要想对View文件的路径进行控制的话,则必须要对IViewEngine接口的FindPartialView或FindView方法进行重写 ...

  6. openEntityForm时候如何给关于(regardingobjectid)类型查找字段赋值?

    本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复264或者20170924可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...

  7. Dynamics 365中使用Web API将查找字段的值设置为空值的方法。

    摘要: 本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复270或者20180424可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyon ...

  8. Dynamics CRM2016 Web Api之查询查找字段的相关属性

    之前有篇博文介绍了如何获取查找字段的name值(跳转),本篇在此基础上再延伸下,实现的效果类似于EntityReference,可以取到查找字段的id,name,localname. 这里我以客户实体 ...

  9. openEntityForm如何给关于(regardingobjectid)类型查找字段赋值?

    本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复264或者20170924可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...

  10. List多个字段标识过滤 IIS发布.net core mvc web站点 ASP.NET Core 实战:构建带有版本控制的 API 接口 ASP.NET Core 实战:使用 ASP.NET Core Web API 和 Vue.js 搭建前后端分离项目 Using AutoFac

    List多个字段标识过滤 class Program{  public static void Main(string[] args) { List<T> list = new List& ...

随机推荐

  1. git知识点,常用命令

    git理论知识 git的服务器端(remote)端包含多个repository,每个repository可以理解为一个项目. 而每个repository下有多个branch."origin& ...

  2. Selenium弹框处理

    Selenium中有三种弹框,本文介绍了处理三种弹框的方法 一.Selenium三种弹框 alert:用来提示,显示一个带有指定消息和确认按钮的警告框 confirm:用于确认,显示一个带有指定消息和 ...

  3. CF980-Div2-D

    CF980-Div2-D 题意 从 \(1\) 开始决策,若选当前数,则累计贡献 \(a[i]\) 并跳到 \(j\) 位置,\(j\) 是 \(\lt i\) 且没有决策过(包括选了和没选)的最大位 ...

  4. mysql skip-name-resolve 的解释

    PHP交流群  717902309 为PHP广大爱好者提供技术交流,有问必答,相互学习相互进步! mysql连接很慢,登陆到服务器上查看mysql日志:IP address 'XX.XX.XX.XX' ...

  5. Gitlab的备份以及密码重置

    关于gitlab代码的备份 要求: 每天备份一次,备份至少7天的数据 备份到远程服务器 开始 编写备份脚本 gitlab_back.sh #! /bin/bash # gitlab 机房备份路径 Lo ...

  6. gal game 杂谈——前言

    gal game 杂谈--前言 大年三十凌晨(早上)打算开始写了吧,作为第一篇先写一些前言好了. 第一次接触gal game还是在B站上看到有人玩<我和她的世界末日>当时觉得挺有意思的,加 ...

  7. 2023NOIP A层联测20 T3 点餐

    2023NOIP A层联测20 点餐 题目很好,可惜考试没想到. 思路 可以按照 \(b\) 从小到大排序,固定选择个数 \(k\),枚举选择的盘子 \(x\) 的 \(b\) 最大,最优解肯定是贪心 ...

  8. NZOJ 模拟赛4

    T1 数字游戏 大家列队后,都觉得累了,于是一起坐到院子中的草地上休息.这时Anna突然想跟她的最大竞争对手Cici玩一个数字游戏,她要你编写程序帮助她取得胜利. 第i次游戏初始时有一个整数N_i(1 ...

  9. JDBC批处理Select语句

    本文由 ImportNew - 刘志军 翻译自 Javaranch.如需转载本文,请先参见文章末尾处的转载要求. 注:为了更好理解本文,请结合原文阅读 在上一篇文章中提到了PreparedStatem ...

  10. tmux之常见问题

    1. 使用tmux ls的时候显示错误 failed to connect to server: Connection refused 解决: 查看进程是否存在 ps -aux|grep tmux 发 ...