Filtering Multiple Models Using a Single Set of Filters (Global Filters)

edited January 3, 2020 in Questions

We're displaying 10 account models on a single page.  All the models have been pre-filtered based on a customer segmention value.  This works fine, but we're having trouble determining how to apply additional filters to all 10 models (global filters).  The user may continue to filter the accounts by a number of additional fields (Sales Rep, Region, Gross Margin, etc.) so the solution here which suggests hardcoding values in the condition(s) isn't feasible.

We've also tried the example in the cross-object conditions post, but again the example is based on hardcoded values.  How do we pass a value selected in one filter into the value field on conditions on other models?  That seems to be the part we're missing.  Thanks!


  • edited October 15, 2019
    I think you can create a condition based on records being in another model. So, you could have one model on which you apply your various filters and conditions and all other models would have one condition that would limit the records to only the records in the first model. You would likely also have to have a model action on your first model to requery all the other models when the first model is requeried. Then each time a filter or condition is applied to the first model, the other models will requery to display the correct records. I am not sure if this will work. Just an idea....
  • edited August 25, 2016
    Thanks Raymond - we're on a similar track.  The part we're missing is when a user sets a filter value on the model that has the filters, how do we pass the value to the conditions on the other models?

    Model 1
    Condition (Always On): Customer_Segment = null
    (Auto) Filter: Sales_Rep

    Model 2
    Condition (Default Inactive): Customer_Segment = 2
    Condition: __autofilter__Sales_Rep__c

    The models load properly with the applicable conditions applied.  When the user selects a Sales Rep from Model 1, two actions are fired.  A JS snippet to make the condition on Model 2 active and set the condition value, and one to reload the models.

    Based on one of the links in my original post, it appears JS is the only way to do this.  If that's true, can someone provide the mechanism to pass the value of Sales_Rep from Model 1 to the corresponding condition in Model 2.

    Thanks again.
  • edited October 17, 2016
    Hey Chad,

    The only way I could determine how to achieve this was indeed with a .js snippet. Using a read-only table with no fields selected, hook one of the models up to the desired filters. For the script to work properly you've then got to ensure that each model you want to be hooked up to the global filter is:

    a) The same Salesforce object type
    b) Has conditions identically named (_autofilter_ conditions work just fine. The fastest and most accurate way to do this is at the XML level.)

    Next you want add a model action to the master model that will sit in the table and be filtered. It will call the following script as a js snippet:

    For a short demo, try this skuid page:
  • edited February 25, 2019
    We are doing "super filtering" in a ton of places on our pages.  Not only for applying a single value across multiple objects, but also same objects in different models - especially aggregate models when we are displaying charts.

    We use UI fields on a "dummy" model and then run a snippet when the user clicks a "search" button.

    So, create a model to hold your Search UI fields.  We have a Look Ups object that we use everywhere for this, and the user has permission to create records in this object (although they never actually save anything to the object.)

    - Add UI fields to your model that are what the user needs to search by (text, picklists, etc.)

     - For your models that you want to affect, create conditions on each model (filter default off).

    For us, we may use a field called "Market" to filter our Contact object, Account object, and Opportunity object.  User wants to select market at the top, and the filter would get applied to all three models on the page.

    Search Model...
    UI field called "Market".  Picklist values = Energy, Oil & Gas, Education.

    Contact Model...
    Condition Market__c = {blank value}, off by default, named MarketContact

    Account Model...
    Condition Market__c = {blank value}, off by default, named MarketAccount

    Opportunity Model...
    Condition Market__c = {blank value}, off by default, named MarketOpportunity

    The snippet looks something like this:

    var params = arguments[0],           
     $ = skuid.$;

    // Declare your search model                       
    var FilterModel = skuid.model.getModel('SearchModel');
    var FilterRow = FilterModel.getFirstRow();
    //**************Include all your Search Fields
    var marketVar = FilterModel.getFieldValue(FilterRow,'Market',true);
    if (marketVar === "") {marketVar = null;}

    // Declare your models you want to affect the conditions on
    var contactModel = skuid.model.getModel('Contacts');

    var AccountModel = skuid.model.getModel('Accounts');

    var OppModel = skuid.model.getModel('Opportunities');

    //***********Declare all Model Conditions 
    var contactMarketCondition = contactModel.getConditionByName('MarketContact');
    var accountMarketCondition = AccountModel.getConditionByName('MarketAccount');
    var oppMarketCondition = OppModel.getConditionByName('MarketOpportunity');

    //***********Deactivate all Model Conditions 
    contactModel.deactivateCondition(contactMarketCondition, false);
    AccountModel.deactivateCondition(accountMarketCondition, false);
    OppModel.deactivateCondition(oppMarketCondition, false);

    //***********Set Model Conditions if search fields are populated
    if(marketVar !== null) {contactModel.setCondition(contactMarketCondition, marketVar, false);}
    if(marketVar !== null) {AccountModel.setCondition(accountMarketCondition, marketVar, false);}
    if(marketVar !== null) {OppModel.setCondition(oppMarketCondition, marketVar, false);}

    // query models with conditions set
        console.log('Contact model updated!');

        console.log('Account model updated!');

        console.log('Opp model updated!');

  • John DahlbergJohn Dahlberg ✭✭✭✭
    edited January 3, 2020
    Here's an updated version of this snippet.  We're in the process of setting up a skuidified reporting package and have created a set of centralized filters that we can plug in via page includes.  This snippet is generalized to accept a source model name and an array of target models as input parameters, which we invoke with a url:


    var src = arguments[0],
        tgt = arguments[1],
    $ = skuid.$;
        s = skuid.$M(src);
        $.each(s.conditions, function(i,condition){
            var sc =;
            if(sc.substring(0,14) == '__autofilter__'){
                co = sc.substring(14);
                co = sc;
                m = skuid.$M(cond);
               c = m.getConditionByName(co);
  • John DahlbergJohn Dahlberg ✭✭✭✭
    edited July 23, 2018
    I should mention that this version also handles autofilters as well.
  • edited March 7, 2019
    Hi John

    Do you have a sample page of this working? I'm not sure what I'm doing wrong, so would be good to see it in action!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!