以下以省市为例:
function preFilterLookup() { //要进行过滤的lookup按钮加入addPresearch事件
Xrm.Page.getControl("shi").addPreSearch(function () { addLookupFilter(); }); } function addLookupFilter() { var sheng= Xrm.Page.getAttribute("sheng").getValue(); //客户类型 if (sheng!= null) { fetchXml = "<filter type='and'><condition attribute='shi.sheng' operator='eq' value='" + sheng + "' /></filter>"; Xrm.Page.getControl("shi").addCustomFilter(fetchXml); } }