I just finished implementing a number of filtered lookups with Michael Höhne's Stunnware Filtered Lookup 4.0. Like most developers I have to think seriously about whether I want to build something vs. pay for someone else's work.
There has been a lot of work put into this product since its introduction with CRM 3.0. The 4.0 release seems pretty well sorted and really makes creating filtered lookups an easy task to accomplish. Supporting the Outlook client, multiple languages, multi-tenancy, and IFD makes this a much better solution then most(probably all) of us would take the time to build on our own.
Filtered Lookups have been reinvented far too many times and become maintenance issues for many upgrading from CRM 3.0 to CRM 4.0. I would rather not have to dig through another guy's failed attempt at this functionality in the future. I personally believe MS should pull this functionality into its product, but barring that, I think using a product like this is the best way to go.
I'm currently using it for a growing list of filtered Lookups for one my customers. This includes some pretty standard lookups like the Account: Primary Contact Lookup, the Case: Responsible Contact, and the Email To:, CC:, and BCC: fields, as well as some for custom fields.
What is typically involved in making a filtered lookup with this tool is the following:
- Settings -> Filtered Lookup: Create a Retrieve Multiple Queries entity
- This may involve using the Fetch Wizard to generate the query.
- Settings -> Filtered Lookup: Create a Single-View Lookup entity
Here is a simple example:
I needed a filtered list for Reseller Accounts on an opportunity.
All in all that took maybe 10 minutes including testing.
The email modifications I made were also very easy to implement as shown in the code that follows. Since the Account is almost always preloaded in the To: field, it was easy to overload the lookups for the target selections to default to the Contacts related to that Account.
For this instance I am still relying on the Form Assistant if the end user wants to select multiple Contacts for a single field or add a CRM user, which is a rare case for this customer. The Form Assistant is not modified by these lookups in any way.
Understanding 3 Important Lines of Code
There are three important lines of code to that you will use to create a filtered lookup.
1. Create a new lookup to override the existing lookup for specified field on the form. In this case the "to" field on the email form.
var toContactLookup = new SwSingleLookup("to");
2. Set a filter parameter that is defined in your Fetch and assign a value.
Below is the Fetch that you can access under settings. Notice the parentcustomerid field in the filter section. You are not limited to a single parameter if you need additional criteria for your filter.
3. Set the class that you are using.
That's it, just save your customization and publish. You now have a working filtered Lookup.
Just the Beginning
These are some very simple examples, but it is obvious how easily much more complex filters could be. If you are going to create complex Retrieve queries, it is worth downloading the Fetch Wizard as well, which is a really easy way to create the XML needed for the fetches that this tool relies on. The Fetch Wizard is part of the Stunnware Tools 4.0. that are available for download at no charge.
If you are playing with the MS CRM 4.0 VPC Image, there is a license for that image that you can download at no cost to test this system out.
If you are considering reinventing this wheel, I seriously recommend trying this solution out first.