function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to add lookup filter for a lookup relationship to Opportunities



I have a custom obj in which I have lookup relationships to both opportunities and account. 

My req is to filter the opps based on the account selected. That is after selecting an account when I click on the opp lookup button I only want the dialog box to show those opps that are related to the selected opp. 


I found that we can use lookup filters for implementing this. But however when I try to edit the particular relationship field in the custom object, it does not show a Lookup filter settings section. But this section does show up for lookup fields on account and user. Why is it not showing up here?



I don't think that the lookup filter would work for you. As it is for static filtering but in your case it would be dynamic. Eg. Based on the Account/Opportunity selected you want to filter only records related to them. This doesn't look possible however you can go to the lookup filed on the custom object and then click on edit link next to the custom lookup filed. From the 'Custom Field Definition' Page scroll down to the 'Lookup Filter' section. click on show Filter Settings and then you would be able to create static filter on the Lookup.

I suppose for your use case you need a Visual Force page and from the controller you need to actually filter the result using JQuery. I don't think this could be achieved without coding.


[Do mark this as solution and give Kudos if it helps you]



You can not filter opportunities with look up filters.