
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 20, 2020 01:31 PM
Ive got this javascript code which lists the records in a view . I want these records to be filtered by the ‘email’ field but i dont know how to include this. please have a look at the code below:

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 20, 2020 03:19 PM
I think you forgot to include your code, so I don’t know specifically what you are working with… I assume this is in the context of the Scripting Block, so I think I can just provide the general guidance that you can use JavaScript’s built in .filter()
method to do this on your queried records. Assuming you’ve queried your records into a variable called records
, it will look something like this:
let filteredRecords = records.filter(record => record.getCellValue("email").includes("@gmail.com"))
In this example, your records would be filtered to return only records where the “email” field includes the sub-string “@gmail.com”, and the resulting array of records would be stored in the filteredRecords
variable.
.filter()
takes an arrow function which it runs on each record ((record => {function block})
. The {function block}
needs to be a piece of code that returns a boolean true/false
as its result. The .includes()
, which we run against the string
returned by .getCellValue()
will return true
if it finds “@gmail” in the email address string, and false
if it does not.
Hopefully that at least points you in the right direction.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 20, 2020 07:29 PM
Seriously!?! Dude - you should write the first Airtable scripting book. This is pure instructional elegance.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 20, 2020 10:31 PM
Jeremy, this is my code… your helps is really appreciated. this code lists all records. please let me know how to filter this records by the email field:
My Pilot Book
-
{{ item['fields']['email'] }}
<p><strong>Registration No.1: </strong>${{ item['fields']['Registration No.1'] }}</p> <p><strong>Registration No.2: </strong>${{ item['fields']['Registration No.2'] }}</p> </li> </ul> </div><!--app-->
