查找视图上的Dynamics CRM自定义过滤器不起作用 [英] Dynamics CRM custom filter on lookup view not working

查看:196
本文介绍了查找视图上的Dynamics CRM自定义过滤器不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线上有几篇文章介绍如何将自定义过滤器应用于查找字段。我以为没有比这更简单的了。

There are a few articles online how to apply your custom filter to lookup field. I thought there couldn't be anything simpler and yet..

function addFilter(accountId) {
//create a filter xml
var filter = "<filter type='and'>" +
    "<condition attribute='parentaccountid' operator='eq' value='"+accountId+"'/>" +
    "</filter>";

//add filter
Xrm.Page.getControl("my_lookup_field").addCustomFilter(filter);
}

我想在查找中快速查找仅查看父帐户为设置为特定帐户。但是,一旦应用此过滤器,视图中将不会显示任何帐户。我真的迷路了。

I want to see in the lookup quick find view only accounts that parent account is set to specific account. Yet once I apply this filter no account will display in the view. I am really lost.

推荐答案

还必须在加载窗体时运行一个函数,该函数调用 addFilter(accountId)函数。像这样的东西:

You must also run a function on load of your form which calls your addFilter(accountId) function. Something like:

function preFilterLookup() {
    var accountId = Xrm.Page.getAttribute("parentaccountid").getValue();

    Xrm.Page.getControl("my_lookup_field").addPreSearch(function () { 
        addFilter(accountId);
    });
}

仅在CRM 2013及更高版本中有效。

This will only work in CRM 2013 and above.

这篇关于查找视图上的Dynamics CRM自定义过滤器不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆