Query a grouped view via JavaScript API?

I have a view that is being grouped by two fields. When I do myView.selectRecordsAsync(); I get a flat list of records, though. Do I have to redo the grouping in JavaScript or is there a way for this to return a nested list that’s the same structure as my grouped view?

Hi @Michael_Henry1 - yes, the records returned from a script query are “flat” and don’t take account of any groups you’ve made in the UI. But the results will take acount of the filters you have applied (if any).

In my experience, not only is the query result “flat”, it is not in the order displayed in the user interface. The results are sorted according to any specified sort, but not sorted according to grouping. Records from different groups may be interleaved with each other.

1 Like

I just ran a test, and the returned records from querying a specific view with grouped records did maintain the group order, including the record order inside each group. Granted it was a small sampling, but I’d like to think that this behavior would extend to larger datasets as well.

1 Like

Awesome. Airtable must have quietly fixed.