Defaulting the search criteria of a lookup

Option 1 – Hard coding the search criteria with a text value


Option 2 – Filtering the lookup search with a value from another lookup

For example when you want to filter the primary contacts lookup on an Account with only the contacts associated to that account by default. The code is split into a function and then  the code to call the function.


document.FilteredLookup = function(criteria, lookup)
    if(criteria == null || lookup == null)
     var filterCriteria = IsNull(criteria.DataValue) ? "" : criteria.DataValue[0].name;
     lookup.additionalparams = "search=" + filterCriteria;

Code to call the function 

document.FilteredLookup(crmForm.all.INSERTFIELD, crmForm.all.INSERTFIELD);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s