//要筛选的查找视图所对应的实体的名称 var entityName = "试听名称"; //displayName,视图的名称,可任意写 var viewDisplayName = "xxx查询视图"; //lookupControl,要弹出查找视图的lookup型字段的名称 var lookupControl = Xrm.Page.getControl("new_Aname"); //id可以为任意一个guid任意填 var viewId = "{3614D729-1AA8-4A6A-85E0-8506D38894D9}"; var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + "<entity name='实体名称' >" + "<attribute name='new_xxxid' />" + "<attribute name='new_name' />" + "<order attribute='createdon' descending='true' />" + "<filter type='and'>" + "<condition attribute='new_xxx' operator='not-in'>" + "<value>30</value>" + "</condition>" + "<condition attribute='new_xxx' operator='in'>" + "<value>140</value>" + "</condition>" + "</filter>" + "</entity >" + "</fetch>"; //object 实体code(必填) 如填写错误查询不出视图 提示信息(未知实体名称) cell查询视图展示的列 var layoutXml = "<grid name='resultset' object='11272' jump='new_xxxid' select='1' icon='1' preview='1'>" + "<row name='result' id='new_xxxx'>" + "<cell name='new_name' width='250' />" + "<cell name='new_number' width='250' />" + "<cell name='new_type' width='250' />" + "</row>" + "</grid>"; lookupControl.addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true); lookupControl.setDefaultView(viewId);