Wednesday, June 8, 2011

A Codeless Universal Search For Dynamics CRM

About a month ago I gate crashed Cloudforce, the Salesforce promotional roadshow. When I was not on their booths showing off Dynamics CRM ( I was attending sessions seeing what they had to offer. One feature which made me jealous was their universal search. For quite a while now Dynamics CRM users have been asking for the ability to search across multiple records at once but short of getting SharePoint into the mix, buying an add-on or coding a solution it is not possible.

This got me thinking whether it would be possible to create a universal search using what we have available through codeless configuration. It turns out it is possible and actually reasonably usable. Moreover, while the solution is built on CRM 2011, I can see no reason why you could not build the same thing in CRM 4.

What Does It Look Like?

Here is the end result:


You type into the quick search the string you want to search on and the results come back. In this case I was looking for Yvonne and got two hits; a lead and a contact. From the results I can now click through to the records.

How Does It Work?

The first step in putting this together is to create a new entity called ‘Universal Search’.


I left the ‘Connections’ tick box ticked but it does not need to be. Similarly, Duplicate Detection can be turned off.

You will now need to create a 1:N and N:1 relationship to each entity you want to search on.


The thing to notice here is I have turned off the Display Option for ‘Navigation Pane Item for Primary Entity’. Doing this for both the 1:N and N:1 relationship results in the creation of a pseudo 1:1 relationship between the Universal Search entity and, in this case, the Account entity. On the form you will be able to look up the other entity but there will be nothing on the side to indicate a relationship.

Here is the Lead record for Yvonne to give you the idea.


Now we have the structure in place we need to add some workflows.

The Workflows

The first workflow creates a universal search record every time an Account is created (or whichever entity you want to search on).


In the universal search record we populate the Name, the keywords field (a new multiple lines of text field to hold the key words we will search on) with the Account values of interest e.g. Account Name, Account Number and we add a link back to the Account.


In the second step of the workflow we then update the Account to link back to the Universal Search record through its lookup.


To reference the record you have created in the previous step, you drop down the ‘Look For’ in the Form Assistant, as in the diagram.

In this case I have added the Universal Search lookup field to the Account form but this is not necessary as workflow allows you to populate fields which are not on the form (you just scroll down the form to the Additional Fields area).

The second workflow updates the Universal Search record if details on the Account change.


In this case we trigger off of a change in the key fields on the Account (Account Name, Account Number). we then update the Universal Search with the new information.


You may have noticed that both workflows are marked as on-demand. In the case of the first workflow, this is needed if you have old records which you want to create Universal Search entries for. In the case of the second workflow, this is necessary if you change the fields you want it to search on as you then have to run it across all the records in the system to update the keywords that will be picked up. Incidentally, if you do adjust the fields you are searching on, remember to reflect this in three places; the create step of the first workflow, the trigger fields in the second workflow and the update fields in the second workflow.

Performing The Search

Once you have performed these steps for all the entities you wish to search on, all you need to do is adjust the Quick Find view of the Universal Search to include the keyword field as a Find Field and add the lookups to the entities you are searching on to the View Fields and you are ready to go. You can add any CRM entity which allows workflows to be run against them and which can be part of a 1:N and N:1 relationship.


As with other codeless solutions, the result is a little clunky but very usable. Probably the biggest downside with this one is the back end maintenance. If you implement this after the records have been created, you will need to run the first workflow against all the old records in the system. Also, if you change you mind about the fields you are searching on, you need to adjust the workflows in three places and run the second workflow against all relevant records. In a database with a large amount of records, this may be inconvenient.

On the plus side, this works in 2011 (and probably v4), is codeless and can be set up in an hour or two. I guarantee that a coded solution cannot get near that kind of turnaround.



Leon Tribe said...

It strikes me you may need a third workflow to handle if the record is deleted. In this case I would change the status of the corresponding universal record to inactive so it no longer appears in the quick search results

Leon Tribe said...

Fellow CRM MVP George Doubinski. Suggested making the Universal Search entity an activity entity and then we can take advantage of the 'Regarding' lookup saving the need to have a column per entity in the quick search view. While this works, I cannot find a way to bring the view into the sitemap short of hacking the xml. So if you are happy to edit the xml, this may be a more elegant solution.

Leon Tribe said...

George has correctly pointed out that rather than hack the xml, we could just access the search through the Activities area of the sitemap. It would require dropping down the activity type but it should work I think.

hero said...

Brilliant Article, I tried this and realised this can be very useful for any company running CRM.

Leon Tribe said...

Hi hero,

Glad you liked it. If you are running CRM 2011, there is an improved version in the blog post following this one using custom activities (

rubikskube said...

Did you have to create the 'keyword' field on the universal search form? Or is that something unique to 2011 (using 4 here)?

Leon Tribe said...

You have to create the keyword field.

Anonymous said...

This is incredibly useful. It works great on most browsers, except it hangs in IE and the browser will not respond to anything until the search is complete. Any thoughts? Thanks again for this.

Leon Tribe said...

These days, there is the excellent Sonoma Universal Search, which may prove useful