代码之家  ›  专栏  ›  技术社区  ›  OfirD

自定义电子邮件的RegardingObject查找下拉列表

  •  2
  • OfirD  · 技术社区  · 7 年前

    我试过自定义电子邮件 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);
    

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

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

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

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

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

    1 回复  |  直到 7 年前
        1
  •  0
  •   Arun Vinoth PrecogTechnologies    7 年前

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

    例如,下面的过滤器将显示 lu_service &删除任何(amp;R) account regardingobjectid 查找。诀窍是 解释 不会有 无效的 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");