我正在尝试筛选产品以使用户更轻松地搜索特定产品。目标是拥有一系列依赖选项集,这些选项集以查找字段结尾,该查找字段仅显示具有先前值的记录。产品都是教科书。链条是这样的:
-年级 -语言 -社论 -组件(例如教科书、练习册、图集等) -产品查询
所有先前的值都是产品表单上可用的选项集,因为每本教科书都有年级、语言、编辑和组件。
我已经找到了如何在线实现依赖选项集和过滤查找,但我找不到将两者联系起来的方法。我尝试仅使用过滤查找,但似乎只有在我为成绩、语言、编辑和组件创建单独的实体并将它们全部关联时才有效。
有人知道我如何实现我的目标吗?
最佳答案
您可以检索选项集的值,然后使用 addPreSearch 过滤查找的方法。
您的代码可能类似于以下代码:
function preFilterLookup() {
Xrm.Page.getControl("productfield").addPreSearch(function () {
addLookupFilter();
});
}
function addLookupFilter() {
var grade = Xrm.Page.getAttribute("gradefield").getValue();
var language = Xrm.Page.getAttribute("languagefield").getValue();
var editorial = Xrm.Page.getAttribute("editorialfield").getValue();
var component = Xrm.Page.getAttribute("component").getValue();
var fetchXml = "";
if (grade != null)
fetchXml += "<filter type='and'><condition attribute='gradefield' operator='eq' value='" + grade + "' /></filter>";
if (language != null)
fetchXml += "<filter type='and'><condition attribute='languagefield' operator='eq' value='" + language + "' /></filter>";
if (editorial != null)
fetchXml += "<filter type='and'><condition attribute='editorialfield' operator='eq' value='" + editorial + "' /></filter>";
if (component != null)
fetchXml += "<filter type='and'><condition attribute='component' operator='eq' value='" + component + "' /></filter>";
Xrm.Page.getControl("productfield").addCustomFilter(fetchXml);
}
关于javascript - 如何使用依赖选项集过滤查找?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37006418/