While working at one of our projects our customer gave me a task to display only active records (in this particular case this was services ) in extended search lookup. The solution appeared to be very simple, but I spent some time before coming to it. Hopefully, this will save someone’s time too.

First I tried to change the exported entity customization file manually adding a filter:

<filter type=”and”>

<condition attribute=”statecode” operator=”eq” value=”0″ />


And while importing it back I did not achieve necessary result. The n I decided to write a simple plugin which would replace a generated fetch xml to the ‘right’ one. Here is the plugin code:

public void Execute (IPluginExecutionContext context)
if (context.InputParameters.Contains («FetchXml»))
string FetchXml = (String) context.InputParameters[“FetchXml”];
//checking that I am working with product
if (FetchXml.Contains («<entity name=\»product\”>”))
//replacing to a necessary fetch xml
context.InputParameters[“FetchXml”] = «<fetch version=\»1.0\”

Then you need to register the plugin: