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
JJmemphisJJmemphis 

How to restrict search results on related objects

I am trying to restrict search results on related objects. Is there a way to do that?

What I have is basically as follows:

I have on a clients profile two fields which relate to eachother in lookups.

States and Vendors.

The layout is like this:

Joe Farm Fresh Produce
FL (Look up, States Object)
Windixii (Look up, Vendors Object)

Now different states have different vendors. FL has Windixii and Walmart but not Costco. On each of the objects Windixii and Walmart Relates to FL and Vica Versa. Such as we have Windixii in FL, GA and CA.

I wanted to know if I have FL selected on the clients file, if there is a way to restrict the lookup on the "Vendors" field to only be those vendors that relate to that state. So if FL is selected only Windixii and Walmart would show when using the Vendors lookup. And if Windixii is selected, when doing the lookup in the "states" field only FL, GA and CA would show.

Any help you can provide on helping me limit these search results is greatly appreciated.
Alain CabonAlain Cabon
Hi,

This is a problem of dynamic dependant picklists that needs some Apex code. 

Static dependant picklists are standard in Salesforce with Controlling Field and Dependent Field.

Two techniques are well explained here; one of which uses <apex:actionSupport> to re-render the dynamic picklist filled with a SOQL query in the Apex controller:  https://greatwavetech.com/visualforce-dependent-picklists/

Under Lightning, there are other examples.
Gerard SashaGerard Sasha
That link did help me  so that I could limit the search results in FL is selected only https://walmartone.live and Windixii.