Conditional Field Filters Based on Other Fields in Table

I need search options in a lookup to be limited based on the value of another field. I could render a different “version” of the field for each scenario, but then I’d end up with 4 columns of the same field in the table since different rows would fall into different scenarios. Is there another way to do this?

Here’s the sitch:
Field A in Row A = Discharge, Field B Options are: Home, Affiliate
Field A in Row B = Leave, Field B Option is: Home
Field A in Row C = Transfer, Field B Options are: Affiliate, Non-Affiliate

It’s likely I’m failing at explaining this so let me know what additional details are needed. I’m trying to avoid this:

                                      Field B V1   Field B V2   Field B V3   Field B V4
Row A = Discharge       Affiliate 
Row B = Leave                                 Home
Row C = Transfer                                                 Non-Affiliate

Lauren,

You can set filter conditions on Lookup fields. Click on the field in the field editor and find the ‘Filters’ tab for the field’s properties. Here is a screenshot:

This is a new opportunity page with a filter set on the Contract lookup field to filter based on the selected Account.

Here is the sample page:

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
    <models>
        <model id="NewOpp" limit="1" query="false" createrowifnonefound="true" datasource="salesforce" sobject="Opportunity">
            <fields>
                <field id="AccountId"/>
                <field id="Account.Name"/>
                <field id="ContractId"/>
                <field id="Contract.Name"/>
                <field id="Contract.AccountId"/>
                <field id="Contract.Account.Name"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <components>
        <basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="NewOpp" uniqueid="sk-1VNq-282" mode="read">
            <columns>
                <column width="50%" uniqueid="sk-1VNq-278">
                    <sections>
                        <section title="Section A" uniqueid="sk-1VNq-279" collapsible="no">
                            <fields>
                                <field uniqueid="sk-1VNt-300" id="AccountId"/>
                            </fields>
                        </section>
                    </sections>
                </column>
                <column width="50%" uniqueid="sk-1VNq-280">
                    <sections>
                        <section title="Section B" uniqueid="sk-1VNq-281">
                            <fields>
                                <field uniqueid="sk-1VNt-301" id="ContractId">
                                    <filters>
                                        <filter type="modelmerge" operator="=" field="AccountId" fieldtargetobjects="Account" value="" model="NewOpp" enclosevalueinquotes="true" mergefield="AccountId" novaluebehavior="deactivate"/>
                                    </filters>
                                </field>
                            </fields>
                        </section>
                    </sections>
                </column>
            </columns>
        </basicfieldeditor>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
        <actionsequences uniqueid="sk-1VNh-245"/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>

Thanks,

Bill

Thanks, Bill. I’m aware of the filters…the problem is that I need more than one based on the value of another field. So ideally, I’d be able to do an if/then filter within that Filter tab, but that’s not possible (at least I don’t think it is?).

So if Field A is set to Transfer Out, then Field B needs to be filtered down to the options of Non-Affiliate or Affiliate. If Field A is set to Leave, then Field B needs to be filtered down to the option of just Home. If Field B is set to Discharge, then Field B needs to be filtered down to the options of Home or Affiliate.

Does that make sense?

Lauren,

I think I understand.  I was assuming that you have a parent-child relationship between the object in Field A and the object in Field B.  I think what you are saying is that you don’t have any relationship between the objects and that you would need more than just a parent-child.  You need a many to many relationship between object A and B.

I think your best option is to setup a junction object between A and B.  Then in your page, setup a model action that runs when Field A is changed.  The action would set a condition on a model on the Junction object for field A, query the model, and bring back a list of object B that you would show in your reference field.

Thanks,

Bill

I run into this in native SF lookup filters as well. Another example is I want to be able to filter down the accounts that return to attach a contact to based on the record type of the contact. I’m not fully following your solution but I think I’ll just need to build it out in a sandbox and see. Thanks!