次の方法で共有


addPreSearch and addCustomFilter in CRM 2013

Using these new methods we can now easily filter the lookup in CRM 2013.

Using addPreSearch we can specify a handler to PreSearch Event. Inside the handler we can specify our fetch xml query that can be used for filtering. The filter applied in the fetch xml will be combined with the any previously added filter as an 'AND' condition.

To remove the filter we can use removePreSearch method.

Here we are filtering the primary contact lookup to show only those records starting with S in the account form.

Account Form Load:-

The filter applies to all the Views.

Active Contacts View

 

Contacts: No Campaign Activities in Last 3 Month View

 

Cheers,
Shraddha Dhingra

Comments

  • Anonymous
    April 20, 2014
    crmjavascripts.blogspot.in/.../how-filter-lookup-in-crm-2013.html

  • Anonymous
    August 03, 2014
    Neo you piggy back rider. Cheap ***.

  • Anonymous
    August 09, 2014
    Please provide an example of addPreSearch with removePreSearch. I am unable to remove the PreSearch.

  • Anonymous
    September 29, 2014
    That filter is lost when the subgrid is refreshed, again very good job of Microsoft.

  • Anonymous
    August 20, 2015
    Hi , I want to use filter-fetch  records which has a same parent purchase id .. so for that i am using your code. function addEventHandler() {        Xrm.Page.getControl("pop_147").addPreSearch(addFilter);   } function addFilter() {    var name = Xrm.Page.getAttribute('new_potitle').getValue();      var filter = "<filter type='and'>" +                                 "<condition attribute='new_parent_poid' operator='eq'  value='" + name + "' />" +                  "</filter>";    Xrm.Page.getControl("pop_147").addCustomFilter(filter); } "pop_147" is subgrid control ..?is it correct or which field i have to replace for that? Please correct me.