Custom CRM Search Feature

Roshan Mehta, 20 May 2010

When I think of search features within CRM, I think of Advanced Find and Quick Find views at the application level, and lookup fields at the entity level. These are extremely powerful features that are all part of the “out-of-the-box” product. Advanced Find allows you to create your own custom queries to find data, and then save the queries as your own views, which you can then share with other users or teams. The Quick Find view is automatically created for you when you define a new custom entity, and allows users to customize which columns are returned in the search results, and which attributes are searchable. Lookup fields allow you to easily locate another related record when working between multiple related entities. Although these are useful in many circumstances, they may not be desirable to use for some client implementations.

For example, I have been working on a custom Contribution entity for a Church. They requested that the entity form allows them to enter data quickly, as they need to record hundreds of Contributions every week. A Contribution needs to be related to a certain Member of the Church, so initially I added a lookup field to the Member form. However, with thousands of church members in the system, it very likely that multiple members can have the same name, so it will be difficult to distinguish between different members, using the lookup field alone. Also, having a window pop-up to select a Member would slow down the process of inputting Contributions, and we were asked if we could include a searchable “Member ID” field to the form. They would then be able to enter a Member ID, and CRM would automatically pull through the Member name into the lookup field, and also populate some address details on the form, so they were certain that they were working with the correct Member.

How it Works
You may already know that CRM allows you to write custom client-side code for most entities, including custom entities. The idea here is to add some Jscript code to the OnChange event of the “Member ID” field. The customizations go even further, as CRM allows you to write code to access the CRM web service from within your client-side code. When the user enters the Member ID into the field and presses tab, the custom code will take that Member ID and try to match it up with a Member record in the system. If it finds a match, it will return the Member name, which is automatically populated into the Member lookup field and will also return the address details and populate these fields on the form. This all happens in a flash, so the user entering the data is totally unaware of what is happening behind the scenes.

This simple custom search feature greatly reduces the time taken to input contributions, as users can now bypass the lookup field pop-up window. It also emphasises the power that CRM provides within its customization features.