Bug ID Number |
BUG-000164286 |
Submitted | January 11, 2024 |
Last Modified | May 27, 2025 |
Applies to | ArcGIS Online |
Version found | Oct 2023 |
Operating System | N/A |
Operating System Version | N/A |
Status | As Designed
After review by the development team, it has been determined that this behavior is as designed. See the Additional Information section for details.
|
Additional Information
This is a known behavior regarding the execution order of filters in feature services. When both viewDefinitionQuery and topFilter are applied to a feature service, the system processes the topFilter first, followed by the viewDefinitionQuery.
To achieve simultaneous execution of both filtering operations, the correct approach is to structure the query using sqlExpression within the viewLayerDefinition instead of using viewDefinitionQuery directly.
The recommended structure is:
json{
"viewDefinitionQuery": "",
"viewLayerDefinition": {
"filter": {
"sqlExpression": "status = 'Active'"
},
"topFilter": {
"orderByFields": "CreationDate DESC",
"groupByFields": "Name",
"topCount": 1
}
}
}
This structure ensures that both the SQL expression filter and the top filter are processed together, providing more precise control over the returned data and preventing unexpected results that may occur when filters are applied in sequence.
Workaround
For query purposes, it is recommended to not add the topFilter parameter on the view definition. Use the queryTopFeatures method to get the correct result.
Steps to Reproduce