自定义电子邮件的aboutobjectid查找下拉菜单

时间:2018-07-11 08:04:29

标签: javascript dynamics-crm dynamics-crm-2015

我尝试使用以下代码来自定义Email的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个有效

我的问题是:1应该工作吗?如果没有,有可能实现这一目标吗?

1 个答案:

答案 0 :(得分:0)

对于2015版中的#1点,您必须使用addPreSearch and addCustomFilter来过滤下拉列表中不需要的实体。这是唯一受支持的方法/解决方法。 Read more

例如,下面的过滤器将显示lu_service并从account查找中删除任何regardingobjectid。技巧为account,不会为空 accountid

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");