1

we have a lookup on custom object to opportunity with lookup filter to only show open opportunities.But, at some point the user closes the opportunity and comes back to update a text area field on the custom Object record. At this point, the lookup filter validates the opportunity and throws an error message value does not match filter criteria.

Any work arounds to validate filter criteria on create but not on edit?

PS:We are using lightning and creating lookup dialog components and customizing the record detail is a lot more effort.

2 Answers 2

0

Unfortunately, filters are all or none. You would have to come up with an alternative means rather than using just a lookup filter, such as a validation rule. That might look like:

AND(ISCHANGED(Opportunity__c), Opportunity__r.IsClosed)

This rule states that when the opportunity field changes, and the new opportunity selected is closed, present an error. This way, you can make the opportunity field lookup filter optional; if they select a wrong value, the validation rule will stop them instead of the lookup filter.

2
  • That makes sense but, we do need the filters because, there are hundreds of opportunities and we only want to show the ones appropriate.
    – Venkata
    Commented Aug 20, 2018 at 16:08
  • @Venkata Yes, you need to make the filters "optional", and rely on the validation rule to enforce the logic.
    – sfdcfox
    Commented Aug 20, 2018 at 16:08
0

We had quite a similar requirement in a recent project.

As @sfdxfox mentioned, you need to make your lookup filter optional. Good thing is, even making lookup filter optional will not have any impact on lightning UI because of this known issue :https://ideas.salesforce.com/s/idea/a0B8W00000GdgjlUAB/ability-for-lightning-to-support-optional-on-lookup-filters

in your case, this issue will work as feature :)

once you mark you lookup filter optional, you can patch your rules via validation which will make sure from backend you are still enforcing the rule during creation or when opportunity is not closed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .