Query a grouped view via JavaScript API?

Topic Labels: Scripting extentions
1889 4
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

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?

4 Replies 4

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.

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.

Screen Shot 2021-12-04 at 10.07.30 PM

Awesome. Airtable must have quietly fixed.