Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

Returning API data with sort order but without filters

Topic Labels: API
2125 8
Showing results for 
Search instead for 
Did you mean: 

I’d like to query a table via the Javascript API with the following requirements:

  1. The query uses a “View” for sort order
  2. The query uses a custom filter that overrides any filters existing on that view.

Is it possible to accomplish this? Right now, it seems that filters in Airtable always affect the API results.

8 Replies 8

No it can’t override the view filters. It would just filter within the view. But you could easily create a new view that doesn’t have your current views filter and query against that.

If I create a new view, then I don’t get the sort order from the original view, right?

you can set up the new view to use same sort as original, right?

You can also provide a sort in the api call to sort any way you want to.

Our view sort is not formula-based, it’s based on manual reordering. Thus, even if the view is duplicated, it will not stay in sync with the “master” view.

Also, the filtering is additive. So, although I can provide a filter to the API, it doesn’t replace the existing filter, hence my original question.

why not add an ‘Order’ field that you modify manually with a number that corresponds with your manual sorting so that you can sort it easily in another view or via api sort functionality

If we implement numbered ordering, we’d lose the nice drag-and-drop functionality which makes our workflow so fast.

When a view is specified during an API request, all returning records will be contained in that view and any filterByFormula parameters will be applied/considered on records contained in that view.

However I’m still a little confused about what you’re trying to accomplish—it sounds like you want to fetch records using the manual sort order defined in by a view yet you want to retrieve records that are NOT contained in that view (by “overriding” the view filters with a custom filterByFormula). Even if you were to accomplish that, how would you anticipate the records from outside the view would be sorted in the results?

The only way I know to have the “best of both worlds” (i.e. a manual sort order from a view with all non-view records appended to then end) would be with two requests:

You could 1) request all manually sorted records from the view and 2) request all records from the table where AND(RECORD_ID() != ‘recXXXX’, RECORD_ID() != ‘recXXXX’, etc) …

What language are you using to connect with the API?