<img src="https://secure.perk0mean.com/176329.png" alt="" style="display:none;">

Dynamics CRM Custom Lookup Feature

By TJ McDowell

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

dynamics crm custom lookup

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

Dynamics crm Account Custom Fields

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

Dynamics CRM Account Form Account Lookup Added
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.
dynamics crm code

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.

dynamics crm code lookup

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.

Tags: account short list, CRM, custom development, custom lookup, addcustomfilter, dynamics crm, dynamics crm custom lookup, dynamics crm dev, Microsoft Dynamics CRM, ms dynamics crm, retrieve multiple records


From start to finish, the expert consultants at Datix understand your business needs and execute software solutions that work.