Dec 01, 2021 06:30 PM
I’m working on an app that needs to filter the table in some way. It doesn’t look like there is a way to update the filters in the app. Is this correct?
Solved! Go to Solution.
Dec 06, 2021 10:30 AM
If you get a Table
instance from a base, there are methods on the table instance (selectRecords()
and selectRecordsAsync()
) that will let you get a RecordQueryResult
. This has a records
property that will return an array of all records on the table. From there you would use the standard JavaScript filter()
method on that array to filter them as desired.
All of this is very similar to how you’d retrieve and filter records in other scriptable parts of Airtable, though the API is slightly different (and more robust). If you’re not already referring to the custom app API docs, I strongly recommend bookmarking it for future reference.
Dec 01, 2021 08:51 PM
Welcome to the community, @JoJo! :grinning_face_with_big_eyes: Are you writing a custom app, or just a script that runs in a Scripting app in the Apps sidebar? Could you please provide more details about your specific situation? Your question is currently pretty broad.
Dec 05, 2021 04:13 PM
Thanks for the reply, Justin! Yes, I’m creating a custom app. It needs to filter the records in a table somehow. I looked for apps that do this, but couldn’t find one. They seem to recreate the table inside the app in full-view mode. Is this this the only approach?
Dec 06, 2021 10:30 AM
If you get a Table
instance from a base, there are methods on the table instance (selectRecords()
and selectRecordsAsync()
) that will let you get a RecordQueryResult
. This has a records
property that will return an array of all records on the table. From there you would use the standard JavaScript filter()
method on that array to filter them as desired.
All of this is very similar to how you’d retrieve and filter records in other scriptable parts of Airtable, though the API is slightly different (and more robust). If you’re not already referring to the custom app API docs, I strongly recommend bookmarking it for future reference.
Dec 06, 2021 10:55 AM
I see – that’s what I had suspected. In that case, I need to recreate the table view in my app.
Dec 06, 2021 11:32 AM
Sorry if I misunderstood something. Are you trying to change the actual table filters; i.e. the filters that drive a view? If so, those can’t currently be accessed—read or written—via any of Airtable’s scripting or app APIs.