Dynamics CRM Custom Lookup Feature

Dynamics CRM Custom Lookup Feature

As a top Microsoft Dynamics CRM consultant, we get a lot of inbound questions regarding development and training related to this powerful CRM. In this installment of our series on free dev tutorials, our team demonstrates a Dynamics CRM custom lookup feature. For more tutorials on Dynamics CRM you can visit our blog.

In Dynamics CRM, the addCustomFilter() function allows a developer to specify criteria to be applied as a filter to a lookup field. Adding filter criteria is easy until the field you want to filter on is not explicitly related to the entity you’re looking up. To help with this, today we’re demonstrating how to spin up a Dynamics CRM custom lookup feature. In this example, we have an “Account Short List” entity that we want to use as a custom filter for an account lookup. We’ve added 3 accounts to the list, but you could add as many accounts as you want.

Executing Dynamics CRM Custom Lookup

We also created a “Test Account” entity that has an Account lookup field.

We’ve added the account lookup field to the Test Account form layout.

One thing that’s important is that if possible, any data query happen asynchronously before the lookup is performed. In this case, we’re getting records from the account short list on page load. The query here does not have to be directly related to the lookup entity. If you have query filter criteria, which you probably will in a real-world scenario, you can use the $filter syntax in your OData query.

At this point, we have a javascript array populated with Account IDs that we want to use in our lookup filter. The fetchXml for the addCustomFilter() function allows an “in” operation. We’ll be using this feature to look for Account GUIDs. We can do a quick javascript loop over the array to build the fetchXml string and add the string as the account field’s filter. As a quick note, to keep the example simple, no check was added for an empty short list, but you should consider this scenario in production code.

Complete Javascript File (Download Here)

Wrap-up — Dynamics CRM Custom Lookup

These tools should help your business successful execute a Dynamics CRM custom lookup feature inside of your instance. There a wide number of uses for this kind of functionality that are not just limited to a sales team. In fact, we’ve done a lot of our development work recently for service-facing organizations that want to mold the CRM to help manage other parts of their business. For more information about our ability to assist with Dynamics CRM custom development, or deployment of Dynamics CRM software system, contact our experts today.

Want More From Your System?

Datix Transforms Business Through Software


More Posts