Dynamics CRM-在父查找为空时删除依赖查找筛选
Dynamics CRM - Remove dependent Lookup Filtering when parent Lookup is blank
在Dynamics CRM 2016*中
我已经使用开箱即用的表单编辑器将"查找"设置为依赖/筛选"父"查找。
因此,当我设置父级查找时,它会根据父级选择过滤子级/依赖项中的选择-如预期/良好。
问题:当我将父级查找设置为空时,筛选将保留并继续根据父级中先前选择的内容来限制依赖的查找选项。我希望它能被删除,儿童查找将不再受到限制。
有JS解决方案吗?我没有添加任何类型的自定义过滤器/视图(因为我使用的是开箱即用的过滤),所以我不确定是否可以删除任何内容来解决这个问题。这是预期的行为吗?
如果开箱即用的依赖查找无法按您想要的方式工作。您可以删除它,并通过JavaScript手动过滤您的查找。如果使用以下代码,则在填充父查找时将筛选子查找。当父查找被清除时,过滤器将从子查找以及中删除
function OnChange_ParentLookup() {
// Manually add pre Search event
// Check if parent lookup is emptied or filled.
if (Xrm.Page.getAttribute("parentLookup").getValue() != null) {
// Remove the previous filter if changing the parent lookup to another value without clearing it first.
Xrm.Page.getControl("childLookup").removePreSearch(addCustomFilterToChildLookup);
Xrm.Page.getControl("childLookup").addPreSearch(addCustomFilterToChildLookup);
}
else {
Xrm.Page.getControl("parentLookup").removePreSearch(addCustomFilterToChildLookup);
}
}
function addCustomFilterToChildLookup() {
// Check if parent lookup is not empty.
// Use value in parent lookup to filter child lookup
var parentLookup = Xrm.Page.getAttribute("parentLookup").getValue();
if (parentLookup == null || parentLookup.length <= 0) return;
// attribute = the field on the child entity that references the parent entity
// uitype = entity name of parent lookup
// value = GUID of the parent lookup
var childLookupFilter = "<filter type='and'><condition attribute='parentLookup' operator='eq' uitype='parentLookupEntityName' value='" + parentLookup[0].id + "' /></filter>";
Xrm.Page.getControl("childLookup").addCustomFilter(childLookupFilter);
}
相关文章:
- JavaScript-如何按类查找元素并删除此类
- Dynamics CRM-在父查找为空时删除依赖查找筛选
- 查找文档,然后在数组中查找条目并将其从数组中删除
- javascript查找字符串并删除以下所有字符
- 使用javascript查找并删除所有出现的短代码
- 查找并删除对象中的空特性
- 查找模式并仅删除几个字符
- 查找文本并将其删除 jquery
- 从对象数组中查找和删除对象
- 如何从服务器中查找和删除临时数据
- 如何查找具有相同 data-* 属性的元素并删除重复项
- 按数据属性查找和删除项目
- 如何从指令中查找和删除 DOM 元素
- 使用纯 javascript 查找并删除特定元素
- 查找和删除对象中的项目
- 使用 PHP 查找并删除一些 javascript 标签,但保留另一个标签
- 每次在文本区域中输入或删除值时运行函数以立即查找总和
- 从数组中查找并删除元素
- 可排序列表+查找已删除的索引
- 正在数组中查找要删除的特定对象