建议用addPresearch或者addCustomFilter吧
var Sdk = window.Sdk || {};
Sdk.filterCustomerAccounts = function () {
//Only show accounts with the type ‘Preferred Customer’
var customerAccountFilter = “”;
Xrm.Page.getControl(“parentaccountid”).addCustomFilter(customerAccountFilter, “account”);
}
//set ‘Sdk.setParentAccountIdFilter’ in the Opportunity form onload event handler
Sdk.setParentAccountIdFilter = function () {
Xrm.Page.getControl(“parentaccountid”).addPreSearch(Sdk.filterCustomerAccounts);
}
在onload的时候注册addPreSearch事件,然后在事件的handdler里面添加方法,判断电工的,就增加过滤
onload的函数里面增加以下代码:
Xrm.Page.getControl(“control_name”).addPreSearch(function () {
addLookupFilter();
});
onload的函数外面添加这个函数
function addLookupFilter() {
var myControl = Xrm.Page.getAttribute(“control_name”).getValue();
if (某某的值为电工或XXXX) {
//给产品添加过滤条件
fetchXml = “”;
Xrm.Page.getControl(“control_name”).addCustomFilter(fetchXml);
}
}