Jul 8, 2007

Filter data in a CRM lookup field

Post from Ronald Lemmen

Curt Spanburgh posted this message on the Sandbox:
Custom Lookup Dialog for Microsoft Dynamics CRM 3.In this post he describes that it is possible to filter the data in a lookup box. He also gives an example which uses data on the form to filter the lookup data. For testing purposes I have used the code below. It should be placed in the form onload of the account entity. It does filter the lookup parent account and will only show accounts which do have a parent account already. Not necessarily useful in a business case, but it does give you a clear example.

crmForm.all.parentaccountid.lookupbrowse = 1;
crmForm.all.parentaccountid.additionalparams = "fetchXml=

crmForm.all.parentaccountid.additionalparams += "&selObjects=1&findValue=0";

As you can see, some extra values are sent to the additionalparams attribute. These are selObjects and findValue. The selObjects should be set to the enity id of the lookup its entity.To help you create fetchXml queries look here:

Using Advanced Find for FetchXml

Great tip Curt!

No comments: