【问题标题】:Customize Email's regardingobjectid lookup dropdown自定义电子邮件的关于objectid 查找下拉列表
【发布时间】:2018-07-11 08:04:29
【问题描述】:

我尝试使用以下代码自定义电子邮件的 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 应该有效吗?如果没有,是否有可能做到这一点?

【问题讨论】:

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


    【解决方案1】:

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

    例如,以下过滤器将显示 lu_service 并从 regardingobjectid 查找中删除任何 account。诀窍是 account 不会有 null 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");   
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-07
      • 2018-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多