For my example today lets presume I need to add a Primary Industry lookup to the Account form. I also need add a Sub Industry lookup where the values shown are determined by what I select as the Primary Industry.
First I need to create two new entities, Primary Industry and Sub Industry. Next I need to create a 1:n relationship between the two new entities with Primary Industry as the Primary Entity. As you can see in the image below I have also set Primary Industry relationship attribute as Business Required so all Sub Industries must have a Primary Industry.
Next I add the Primary Industry attribute to the Sub Industry form.
In order to be able to filter the Sub Industry lookup based on the selected Primary Industry value I need to add the Primary Industry attribute as a find column in the Sub Industry Lookup View. I can now publish my two new entities.
I add some values to my Primary Industries and my Sub Industries.
Now I need to add the Primary and Sub Industry lookups to my Account form. I create a n:1 relationship between the Account entity and my Primary Industry and Sub Industry entities. In each case the Account Entity will be the Primary Entity. I can then add the created Primary Industry and Sub Industry lookup attributes to the Account form as shown below.
var lookupItem = new Array;
lookupItem = crmForm.all.new_primaryindustryid.DataValue;
var searchVal = lookupItem.name;
crmForm.all.new_subindustryid.additionalparams = ‘search=' + searchVal;
I can now publish all my changes and test the result. As you can see below because I selected Finance as the value for my Primary Industry, when I click on the lookup for the Sub Industry it is “pre-filtered” and only shows the Sub Industries that relate to Finance.