Filter models by value NOT IN another model not working

  • 1
  • Problem
  • Updated 2 years ago
I'm filtering model 2 to include values not in model 1. When model 1 returns records, everything works correctly. When model 1 returns zero records, model 2 continues to use the previous query no matter what I do.

How can I resolve this?
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
In the settings for your "field from another model" there are options for what to do if the model doesn't have any rows. Make sure you have that set to operate the way you want.
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
Thanks for the quick response.

I've tried both options. Neither changes the behavior.

In addition, I've tried multiple iterations of deactivating the conditions and querying in different orders, nothing seems to change the behavior (except completely removing the filter).

Also, I've checked in the console to verify that model 1 is returning zero rows, and that model 2's query still includes the filter condition from the previous query (where model 1 had records).

I'm pretty confident this is a bug, I just don't know of a workaround.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Brayden,

Can you send the xml for the two models? How are you initiating the queries?
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
XML is below. I'm initiating the queries with actions from the action framework. Based on the testing I've done so far, it appears the "If no row in Source Model" behaviour is not working. It does not deactivate the condition when there are no rows.

    <model id="SummaryDocuments" limit="20" query="false" createrowifnonefound="false" adapter="" type="" sobject="Summary_Documents__c" doclone="">
<fields>
<field id="Summary_Log_Id__c"/>
<field id="Summary_Log_Id__r.Name"/>
<field id="Document_Log_Id__r.Title__c"/>
<field id="Vendor__c"/>
<field id="Product__c"/>
<field id="Document_Type__c"/>
<field id="Date_Received__c"/>
<field id="Document_Log_Id__c"/>
<field id="Document_Log_Id__r.Name"/>
</fields>
<conditions>
<condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Summary_Log_Id__c" state="filterableon" inactive="false" name="Summary_Log_Id__c" operator="="/>
</conditions>
<actions/>
</model>
<model id="VendorDocumentsPU" limit="25" query="false" createrowifnonefound="false" adapter="" type="" sobject="Document_Log__c" doclone="">
<fields>
<field id="Vendor__c"/>
<field id="Vendor__r.Name"/>
<field id="Vendor_Products__c"/>
<field id="Vendor_Products__r.Name"/>
<field id="DocumentType__c"/>
<field id="Document_Date__c"/>
<field id="Period_Begin_Date__c"/>
<field id="Name"/>
</fields>
<conditions>
<condition type="modelmerge" value="" field="Vendor__c" operator="=" model="VendorAccounts" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="deactivate"/>
<condition type="modelmerge" value="" field="Id" operator="not in" model="SummaryDocuments" enclosevalueinquotes="true" mergefield="Document_Log_Id__c" novaluebehavior="deactivate" state="filterableoff" inactive="true" name="Id"/>
<condition type="multiple" field="DocumentType__c" operator="in" inactive="true" enclosevalueinquotes="true" name="__autofilter__DocumentType__c" state="filterableoff" value=""/>
<condition type="fieldvalue" field="Period_Begin_Date__c" operator="gte" inactive="true" enclosevalueinquotes="false" name="__autofilter__start__Period_Begin_Date__c" state="filterableoff" value=""/>
<condition type="fieldvalue" field="Period_Begin_Date__c" operator="lte" inactive="true" enclosevalueinquotes="false" name="__autofilter__end__Period_Begin_Date__c" state="filterableoff" value=""/>
</conditions>
<actions/>
</model>
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Two options:

1. (Preferred) Instead of a 'field from another model' condition, just use a single specified value condition, leave the value blank, filterable default off. Then in your action sequence use the 'activate and set value' action to set the value, then query.
2. in your action sequence instead of just querying model 2 after activating the condition, query both models in the same action.
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
This has really become an issue as I continue to build out our new interface. This seems to be what happens:

-The automatic IN condition is set based on values from the source model
-If the source model is re-queried and returns no records, the IN condition is not deactivated, the condition continues to have the previous values
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb