Skip to main content

Problem: I need to be able to dynamically filter lookup values based on another lookup field.


Example below:


My Custom Account Object has two lookup fields; System Type(System Type Object) and Vendor(Vendor Object). When I select a value for System Type I’d like the Vendor field to only display results that pertain to the System Type. The mapping between System Type and Vendor is contained in a VendorSystemType Junction object.


For example, let’s say I select Finance for my System type. The Vendor field should only display results that have System Type = “Finance” from the VendorSystemTyp Junction Object. Those results would be SAP & Oracle.


Any help is appreciated!


Josef,


I think I”ve found a way to do what you want. I’ll describe it to you in terms of your objects but the screenshots are where I did the same thing for the Task object, using WhoId and WhatId (contacts and opportunities so I could take advantage of the OpportunityContactRole object as the junction object to limit contacts based on the opportunity chosen). In this case opportunities are analogous to system type and contacts are analogous to vendor.


First, add a model for the VendorSystemType junction object to your page. It only needs to include its own Id and the VendorId and SystemTypeId relationship fields. Add a filterable default off condition on it for the SystemTypeId field:



Next, add an action to your custom Account model. The action should be initiated by row in model updated, and specifically when the SystemTypeId field is updated:



The action to take is “Activate and Set value of model condition” on the junction model. Set the SystemTypeId condition on it to be something like {{SystemTypeId}}. You’re using merge syntax to pull the value of the SystemType field from the account object’s current row (I was pulling the Opportunity Id which was stored in WhatId for tasks). You also need a second action - query the junction model:



The last step is to add a filter on the Vendor field on the field editor for the account object. The filter should say that the Id (the Vendor Id, since we’re looking at the Vendor object through the relationship) is in the VendorId from the junction model. You can get to the Filters section by clicking on the field in the field editor, and then clicking the Filters section:



the filter setup:



Once you’ve got all this setup, the flow should be: you pick a System Type and that triggers the action to set the condition on and query the junction object. Then, because the Vendor field is filtered to only show results from the junction object it updates and you only see Vendors that are connected to the System Type.


Hope this works out for you!