CRM MVP Mitch Milam returns as a guest blogger.
Occasionally I get a request from a customer to create a custom search screen that will allow them to perform specific queries that they use on a frequent basis. Usually, I point them to the Advanced Find feature and have them save their Advanced Find query as a Saved View. This process works for the majority of customers, but one of my current projects had a requirement to make this type of process a little more user friendly.
Not wishing to reinvent the wheel, I started looking at the Advanced Find and View functionality and created what I think is a fairly elegant solution.
Creating a Custom Search View
Working with the Contact Entity, we start this process by creating a new system view called Date Range Search – Active Contacts, which will look like the following:
Our filter criteria will look like this:
As you can see, we’ve created an AND search using the Created On Attribute looking for a start date that is On or After a specific date AND the end date is On or Before a specific date. This AND grouping will give us the net effect of Between. At this point, the dates entered are not actually relevant to our query. They are merely placeholders since CRM requires us to enter a date before saving the Filter Criteria.
We also check the Status Attribute and make sure that we only return Active records.
After you’ve finished defining the new view, save the view then publish your changes to make them available.
Capturing the Advanced Find URL
Now we need to determine the URL used by CRM to display the filter criteria we used to create the Date Range Search – Active Contacts view. Perform the following steps:
Open the Date Range Search – Active Contacts view:
Click on the Advanced Find button to display the filter criteria for the current view:
We need to capture the URL that is used to display this form. The quickest way to make that happen, is to press Ctrl+N to instruct Internet Explorer to open a new window. It will display like this:
Copy the URL from the address bar then close both of the Advanced Find windows.
The URL captured on my system looks like this:
Modifying the ISV.Config file ( CRM 3.0 )
We’re going to add a button to the Contacts grid that will allow our users to activate the new search feature. This operation is performed by editing the isv.config.xml file found in the folder:
Locate the Entities section, located toward the bottom of the file and replace this code:
<Entity name=”contact” />
With the following code:
Title=”Date Range Search”
ToolTip=”Perform a Date Range Search”
And place it inside the window.open command. This will guarantee that the URL matches the configuration of your system exactly.
Note: You will notice that the ampersands ( & ) found in the URL have been replaced with &. Since the isv.config is an XML file, we need to “encode” them so that the XML parser doesn’t try to “interpret” the ampersand as a command and thereby destroying our URL.
After editing the isv.config file, you’ll need to refresh your browser to make the new customization display. You may also need to delete your temporary Internet files.
Modifying the ISV.Config file ( CRM 4.0 )
The process for CRM 4.0 is very similar to that of CRM 3.0 except for the fact that you need to Export your isv.config file then add replace <Entity name=”contact” />
<Title LCID=”1033″ Text=”Date Range Search”/>
<ToolTip LCID=”1033″ Text=”Date Range search for active contacts” />
Note: You will need to replace “[orgname]” with the name of CRM Organization. This will be especially important in a multi-tenant environment.
After you’ve imported your changes, you’ll need to refresh your browser to make the new customization display. You may also need to delete your temporary Internet files.
Putting Date Range Search to Use
After the customization had been added, you’ll now see a new button on the Contacts grid:
Clicking the Date Range Search button will display the following form:
All the user has to do at this point is to change the start and end dates and click the Find button to execute the search.
While this may not seem to be a huge deal, it does save the user a few seconds ( and a click or two ). If performed several times per day, the savings starts to add up.
This example is uses the Contacts Entity but it can be applied to any standard or custom CRM Entity.