自定义电子邮件的相关对象ID查找下拉列表



我尝试使用以下代码自定义电子邮件的regardingobjectid查找下拉列表:

var regardingobjectid = Xrm.Page.getControl("regardingobjectid");
/* The value of viewId is a dummy value, 
and only needs to be unique among the other available views for the lookup. */
var viewId = '{00000000-0000-0000-0000-000000000001}';
var entityName = 'lu_service';
var viewDisplayName = 'service - custom view';
var fetchXml =
'<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >' +
'<entity name="lu_service">' +
'<attribute name="lu_serviceid" />' +
'<attribute name="lu_name" />' +
'<attribute name="createdon" />' +
'<order attribute="lu_name" descending="false" />' +
'</entity>' +
'</fetch>';
var lookupService = new RemoteCommand("LookupService", "RetrieveTypeCode");
lookupService.SetParameter("entityName", "lu_service");
var result = lookupService.Execute();
var objectTypeCode = result.ReturnValue;
var layoutXml =
'<grid name="resultset" object="' + objectTypeCode + '" jump="lu_name" select="1" icon="1" preview="1">' +
'<row name="lu_service" id="lu_serviceid">' +
'<cell name="lu_name" width="300" />' +
'<cell name="createdon" width="125" />' +
'</row>' +
'</grid>';
regardingobjectid.addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);

我认为这个代码应该做两件事:

1.自定义查找下拉列表,即在单击查找字段时显示的下拉列表上显示所需类型的记录(在我的示例中为:lu_service(。

2.在单击"查找更多记录"链接(列在查找下拉列表的末尾(时打开的窗口中添加自定义视图。

结果是1不起作用,2起作用

我的问题是:我应该工作吗?如果没有,有可能做到这一点吗?

对于2015版本中的第1点,您必须使用addPreSearch和addCustomFilter来过滤掉下拉列表中不需要的实体。这是唯一支持的方法/解决方法。阅读更多

例如,下面的过滤器将显示lu_service&从regardingobjectid查找中移除任何account。诀窍是account不会有nullaccountid

var serviceFilter = "<filter type='and'><condition attribute='lu_serviceid' operator='not-null' /></filter>";
//remove accounts
var accountFilter = "<filter type='and'><condition attribute='accountid' operator='null' /></filter>";
Xrm.Page.getControl('regardingobjectid').addCustomFilter(serviceFilter, "lu_service");
Xrm.Page.getControl('regardingobjectid').addCustomFilter(accountFilter, "account");   

最新更新