简体   繁体   English

Dynamics CRM 2016编辑来自字段的查找电子邮件

[英]Dynamics CRM 2016 edit lookup email from field

I am using Microsoft Dynamics 2016, and need to clean up the options in the from field of the default email form. 我正在使用Microsoft Dynamics 2016,需要清理默认电子邮件表单的from字段中的选项。

So the aim is to limit the results in the lookup for the email "from" field. 因此,目的是限制查找电子邮件“来自”字段的结果。 By default it shows all companies, contacts etc. However, we will only be using queues and users in the "from" field. 默认情况下,它会显示所有公司,联系人等。但是,我们只会在“来自”字段中使用队列和用户。

How can I limit the lookup and search items to only use queues and users? 如何限制查找和搜索项目仅使用队列和用户? It appears that this is derived from a party list, however, I can not find any information on editing a party list inputs. 看来这是从派对列表中派生出来的,但是,我找不到有关编辑派对列表输入的任何信息。

I thought maybe https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_addCustomFilter would be an option, but can't work out how to feed the attribute types of queue (2020) and user (8) in to form the lookup. 我想也许https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_addCustomFilter是一个选项,但无法解决如何提供队列(2020)和用户的属性类型(8) )以形成查找。

Using some code from https://social.microsoft.com/Forums/en-US/3b97a306-4df7-4128-a3a9-e516c46c565d/limit-customer-lookup-in-opportunity-to-accounts-only?forum=crmdevelopment I came up with the following code: 使用https://social.microsoft.com/Forums/en-US/3b97a306-4df7-4128-a3a9-e516c46c565d/limit-customer-lookup-in-opportunity-to-accounts-only?forum=crmdevelopment I中的一些代码想出了以下代码:

function setFromLookupOptions()
{
    document.getElementById("from").setAttribute("lookuptypes", "8,2020");
}

However, this code just brings up errors, saying it cant setAttributes of Null (indicating it can not find the "from" field, but that's what it's labelled in the form). 但是,这段代码只会出现错误,说它无法设置Null的setAttributes(表示它找不到“from”字段,但这就是它在表单中标注的内容)。 I have also tried using "from_i" as per the note at the top of the first block of code at https://bernado-nguyen-hoan.com/2015/10/28/correcting-available-lookup-views-when-restricting-lookup-types-via-javascript-in-crm/ however, it can't seem to find an element with that name. 我还尝试使用“from_i”按照https://bernado-nguyen-hoan.com/2015/10/28/correcting-available-lookup-views-when-第一段代码顶部的说明限制-look-types-via-javascript-in-crm /但是,它似乎找不到具有该名称的元素。

So how can I do this? 那我该怎么做呢?

There is a bit more to do with this here: https://community.dynamics.com/crm/f/117/t/186549 and the script I created to do this is: 这里还有一点与此有关: https//community.dynamics.com/crm/f/117/t/186549 ,我创建的脚本是:

/*
Function to only select certain entities in a lookup

To use, just edit fieldName to be the name of the field on the form you want to edit and HideEntities as an array of entities you do not want to show up.
Note that under the advanced search, you will still see these items in the drop down list, they just wont find any results.
/*

function setFromLookupOptions()
{
  var fieldName = "from";
  var HideEntities = ["customJob", "account", "contact","entitlement", "equipment", "lead"];
  Xrm.Page.getControl(fieldName).addPreSearch(function()
  {
    EmailFilter(fieldName, HideEntities);
  });
}

// Hide all of the OOB entity records from the given PartyList field.
function EmailFilter(fieldName, HideEntities)
{
  var filter;
  var i;
  for (i = 0; i<HideEntities.length; i++)
  {
    filter =
      "<filter type='and'>" +
      "<condition attribute='" + HideEntities[i] + "id' operator='null' />" +
      "</filter>";
    Xrm.Page.getControl(fieldName).addCustomFilter(filter, HideEntities[i]);
  }
}

I hope this helps someone. 我希望这可以帮助别人。

Note that customJob is any other field that is showing up that you need to remove. 请注意,customJob是显示您需要删除的任何其他字段。 All other instructions are at the top of the script. 所有其他说明都位于脚本的顶部。

for CRM2016 you can try this to show only lead and account entities in lookup popup. 对于CRM2016,您可以尝试在查找弹出窗口中仅显示潜在客户和帐户实体。

var control = Xrm.Page.getControl("to");
control.getAttribute().setLookupTypes(["lead", "account"]);

Somewhat related for someone else who may find this thread & wants something a bit simpler: 与其他可能找到这个帖子并想要更简单的东西相关的东西有点相关:

I wanted to set the lookup to only contacts and users for the party list/attendees in an Appointment. 我想将查找设置为仅限约会中的聚会列表/与会者的联系人和用户。 This code works: 此代码有效:

var lookupAttendees = Xrm.Page.getAttribute('requiredattendees').getLookupDataAttribute(); lookupAttendees.setLookupTypes(['contact', 'systemuser']);

Notes: The party list cannot contain records that have been not included (eg anything but contact and systemuser). 注意:聚会列表不能包含未包含的记录(例如,除联系人和systemuser之外的任何内容)。 So be sure to clear the party list of Accounts/Leads/etc. 所以一定要清除账户/线索/等的聚会清单。 before running this code, otherwise it won't do anything. 在运行此代码之前,否则它将不会执行任何操作。

Assuming that this could potentially work for any type of party list, even in email entity. 假设这可能适用于任何类型的聚会列表,即使在电子邮件实体中也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM