Below is a simple JavaScript code to achieve that.
- On the forms OnLoad event write the following code.
FilterLookup = function(source, target)
{
if (IsNull(source) || IsNull(target)) { return; }
var name = IsNull(source.DataValue) ? '' : source.DataValue[0].name;
target.additionalparams = 'search=' + name;
}
- On the OnChange event of the Parent Account lookup mention the below code.
FilterLookup(crmForm.all.parentaccountid, crmForm.all.primarycontactid);
Note : Before you can see the code working, check the Parent Customer checkbox in the Contact Lookup View. Steps ->
- Settings > Customization > Customize Entites > Contact > Forms & Views > Contacts Lookup View
- Click on Add Find Columns on the right
- Tick Parent Customer
- Click OK and Publish
The Contact lookup opens(as shown in the figure below) and you can see "A Bike Store" in the search box & CRM is only returned those Contact records whose Parent Customer is "A Bike Store."