Troubleshooting: Date range filter doesn’t work
PROBLEM: When you click on a date range filter, it doesn’t affect the table.
RESOLUTION: The filter's conditions needed to be added to the model’s condition grouping logic for the filter to be applied.
A client discovered that one of their date range filters wasn’t being respected. You could enter dates in the filter, but the table wouldn’t reload. A similar filter worked elsewhere in the app, but not on that specific tab.
- Since the client had an example of a place where the filter was working, I compared the working filter to the broken filter to ensure that they were set up identically.
Both filters appeared to be identical. Both were set to pick options and conditions automatically.
2. When a filter is set to pick options and conditions automatically, it will auto-create the filter condition(s) on the model. I verified that the autogenerated conditions appeared on the appropriate model (named Opportunities).
3. Next, I made sure that Created Date, the field the filter was using, was included in the Opportunities model. Sometimes there can be issues if a condition’s field is not included in the model.
4. I thought there might be an irregularity with the page XML, so I opened the XML View. In the XML View, I realized that the model had grouping logic determining which of its conditions to apply, and that the filter conditions were not included in this logic. Since the filter conditions were not included in the condition logic, the model didn’t know under what conditions they should be applied. Because of this, the filter couldn’t be respected.
Updating the condition grouping logic to include the filter’s conditions allowed the filter to function as expected. I added the filter’s conditions (3 and 4) to the Condition Grouping logic, as shown below. Updated logic: (1 OR 2) AND 3 AND 4
Filters work by manipulating model conditions. If you encounter an issue with filters, the first things to check are the filter’s condition and the related field.
If you are using condition grouping logic and filters, make sure the filter conditions are included in the grouping logic using AND statements.