将“查找"字段设置为仅显示联系人
我有一个查找字段,其中显示了对4个实体的查找.因此,我添加了预搜索过滤器"以仅在单击字段时过滤联系人.但是,当我单击查找更多记录时,我希望仅在联系人"实体上进行搜索.
I have a lookup field which shows a lookup for 4 entities. So, I have added the PreSearch Filter to filter only the contacts when I click on the field. But, when I click on Look for more Records, I want the search to be made only on Contacts entity.
我只想在下图上看到联系人实体:
I want to see only Contacts entity on the following image :
有可能吗?
无法从列表中隐藏那些相关实体.但是我们可以禁止用户在该查找中选择任何其他不需要的实体记录.
It’s not possible to hide those related entities from the list. But we can disallow the users to choose any other unwanted entity records in that lookup.
我们必须使用 addPreSearch
和 addCustomFilter
.例如,要允许用户仅选择联系人而不选择帐户或系统用户,请参见以下代码段.这将过滤出帐户&系统用户从&视图中的记录用户只能通过选择联系人来前进.
We have to use addPreSearch
and addCustomFilter
. For example, to allow users to choose only contact but not account or systemuser, see the following snippet. This will filter out account & systemuser records from the view & users can move forward only by choosing contact.
var contactFilter = "<filter type='and'><condition attribute='contactid' operator='not-null' /></filter>";
//remove accounts
var accountFilter = "<filter type='and'><condition attribute='accountid' operator='null' /></filter>";
//remove system users
var systemUserFilter = "<filter type='and'><condition attribute='systemuserid' operator='null' /></filter>";
Xrm.Page.getControl('requiredattendees').addCustomFilter(contactFilter, "contact");
Xrm.Page.getControl('requiredattendees').addCustomFilter(accountFilter, "account");
Xrm.Page.getControl('requiredattendees').addCustomFilter(systemUserFilter, "systemuser");
修改:
添加另一个未记录的文件(因此不受支持),直到8.x
Adding another undocumented (hence unsupported) till 8.x
Xrm.Page.getAttribute('your_field').setLookupTypes(['contact']);
9.x已记录&支持的方式:
9.x documented & supported way:
Xrm.Page.getControl('your_field').setEntityTypes(['contact']);
更新 :(替换上述不赞成使用的语法)
Update: (replacement of above deprecated syntax)
function onFormLoad(executionContext) {
var formContext = executionContext.getFormContext();
formContext.getControl('your_field').setEntityTypes(['contact']);
}