cross model linked conditions

The javascript snippet to enable this was relatively easy.

var $ = skuid.$, eliteAgentAccounts_Ag = skuid.$M('EliteAgentAccounts_Ag'), eliteAgentAccounts_Basic = skuid.$M('EliteAgentAccounts_Basic'); $.each(eliteAgentAccounts_Ag.conditions, function(i,condition){ var agConditionName =, basicCondition = eliteAgentAccounts_Basic.getConditionByName(agConditionName); if(condition.inactive) { eliteAgentAccounts_Basic.deactivateCondition(basicCondition); } else { eliteAgentAccounts_Basic.activateCondition(basicCondition); eliteAgentAccounts_Basic.setCondition(basicCondition,condition.value); } });<br>

Pat, you’re a legend! I was only today, thinking about how to have one date picker that will filter a bunch of other models. Mucho useful for charting, as well as building dynamic report type pages.

Pat is taking a page out of my book.  Asking a question and then answering it himself.  That’s awesome.  But we do miss the hats. 

Pat, I had a rock star developer who worked for me when I ran a start up moons ago. He worked remotely and there were days that he went w/o seeing daylight. Your picture reminder me (fondly) of that developer. Rock on, dude. Irvin

Pardon the javascript newbie…

I have 2 aggregate models that are identical except the 2nd doesn’t have any groupings (so I can have call-out numbers).  I basically did a find and replace with the code here (I replaced the basic model with my model without groups and the other with my aggregate that has the table filters). The display numbers aren’t being filtered…

It’s an in-line (snippet) as follows:

var $ = skuid.$,&nbsp; &nbsp; oppyAggregate = skuid.$M('OppyAggregate'),<br>&nbsp; &nbsp; oppyAggregatetoDisplay = skuid.$M('OppyAggregatetoDisplay');<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; $.each(oppyAggregate.conditions, function(i,condition){<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; var agConditionName =,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; basicCondition = oppyAggregatetoDisplay.getConditionByName(agConditionName);<br>&nbsp; &nbsp; &nbsp; &nbsp; if(condition.inactive) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oppyAggregatetoDisplay.deactivateCondition(basicCondition);<br>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oppyAggregatetoDisplay.activateCondition(basicCondition);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oppyAggregatetoDisplay.setCondition(basicCondition,condition.value);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>



Joe, I’m not sure if this is the same issue that you’re having, but I found that Pat’s original snippet doesn’t handle unnamed conditions that are always active - I had to slightly tweak it to get it to work for my models.

I added one extra if statement to my snippet

if(!agConditionName) {
return true;

Here’s a modified version of your snippet that incorporates it.

var $ = skuid.$, oppyAggregate = skuid.$M(‘OppyAggregate’),
oppyAggregatetoDisplay = skuid.$M(‘OppyAggregatetoDisplay’);

$.each(oppyAggregate.conditions, function(i,condition){

var agConditionName =,
basicCondition = oppyAggregatetoDisplay.getConditionByName(agConditionName);
if(!agConditionName) {
return true;
} else if(condition.inactive) {
} else {

Joe,  I don’t immediately see anything wrong with your code.   Would you mind giving us login rights to your org so we can take a look at what is going on?   Here is how:
1. Use this tutorial to give us login rights:….
2. Then send an email to  with the name of the page. 
We’ll see what’s going on…

Here are  a few clarifications we found about Pat’s snippet. 

1. Implementation: 
- This snippet should be of type “Inline Snippet”
- You need to create a model action on the first model (the one that has filters on it) that is triggered when you requery the model. 
- The actions need to be “Run Snippet” and “Query Model” - choosing the second model. 

2. Limitations: 
- This code will not work for multipicklist conditions.  There is a diffent API method for passing values into multi-picklist conditions. 

You guys are geniuses, and by geniuses, I mean the kind of people whose code the rest of us cannibalize so we can live another day without learning Javascript.

Here’s the XML for a page that demonstrates this in action, for my fellow copy-pasters. It has 3 models queried with one filter, that I created for this topic. Yay!

``` Contacts Tasks models.loaded This filter, though. Leads Contacts Tasks Leads Contacts Tasks Leads Tasks var $ = skuid.$, Leads = skuid.$M('Leads'), Contacts = skuid.$M('Contacts'), Tasks = skuid.$M('Tasks'); $.each(Leads.conditions, function(i,condition){ var LeadConditionName =, ContactsCondition = Contacts.getConditionByName(LeadConditionName) TasksCondition = Tasks.getConditionByName(LeadConditionName); if(condition.inactive) { Contacts.deactivateCondition(ContactsCondition), Tasks.deactivateCondition(TasksCondition); } else { Contacts.activateCondition(ContactsCondition); Contacts.setCondition(ContactsCondition,condition.value); Tasks.activateCondition(TasksCondition); Tasks.setCondition(TasksCondition,condition.value); } }); .hidetablefooter .nx-list-footer { display:none; } ```

Hi Ana,

Should this work with using a Date Range filter. 



I would not be suprised if this DOES NOT work with Date Range filters. 

So far I have not been able to get this to work with a Date Range. Do you know of another way that a date range can work on a table and its drawer?

interesting. Table model and drawer model. Should still work. You may have to modify snippet slightly.

Not sure about updating already opened drawer though.

Tami / Rob - 

If you use a date range with manual conditions it should work (I have it working on several pages). You may not be able to do it with the the automatically generated date range conditions.


Can you explain more about the manual conditions? I have a date range with manual condition set on the parent table. How would I go about having it also change the drawer data?


I tried your snippet with a date range and I couldn’t get it to work. Further inspection of how the date range shows in the console and the “value” section doesn’t get filled in. There are two conditions that need to be changed a Start and End date. Perhaps your snippet could work with some changes but I am not versed enough at this point to know what those changes should be.


Here are two snippets, modified from Pat’s. The first I use to initialize the date range on the primary model on pageload. The second I use to link the conditions each time the primary model is queried. You need a conditions called “StartDate” and “EndDate” on each model that you want to link.

<jsitem location="inline" name="initializeDateConditions" cachelocation="false" url="">(function(skuid){
var $ = skuid&#46;$;
var dateRangeModel = skuid&#46;$M('Cases'),
    startDateCondition = dateRangeModel&#46;getConditionByName('StartDate'),
    endDateCondition =  dateRangeModel&#46;getConditionByName('EndDate'),
    startDate = new Date(),
    endDate = new Date(),
    startDateOffset = -15,
    endDateOffset = -1;
    startDate&#46;setDate(startDate&#46;getDate() + startDateOffset);
        endDate&#46;setDate(endDate&#46;getDate() + endDateOffset);
        var startConditionValue = skuid&#46;time&#46;getSFDateTime(startDate),
            endConditionValue = skuid&#46;time&#46;getSFDateTime(endDate);
        dateRangeModel&#46;setCondition(startDateCondition, startConditionValue);
        dateRangeModel&#46;setCondition(endDateCondition, endConditionValue);
      <jsitem location="inlinesnippet" name="linkConditions" cachelocation="false">var $ = skuid&#46;$;
var startValue = skuid&#46;$M('Cases')&#46;getConditionByName('StartDate')&#46;value,
    endValue = skuid&#46;$M('Cases')&#46;getConditionByName('EndDate')&#46;value;
var targetModels = [];
$&#46;each(targetModels, function(){
   this&#46;setCondition(this&#46;getConditionByName('StartDate'), startValue);
   this&#46;setCondition(this&#46;getConditionByName('EndDate'), endValue);

After you run the linking script, you’ll need to query the linked (drawer) model.