Count Number of Records in a view

Goal: Send a daily email using airtable app triggered by time, linked to a view. The problem is airtable limits the count to 100 records and these views contain more than 100 records.

I need a script that counts the number of records in a view. Thats it. I’ve searched the forums but have not been successful at figuring this out. Any help would be greatly appreciated.

Welcome to the Airtable community!

const table = base.getTable("Table 1")
const view = table.getView("My View")
const queryResult = await view.selectRecordsAsync({fields: []})
const numRecordsInView = queryResult.records.length
console.log(numRecordsInView )

Awesome! This worked however when i try to reference it in the email automation i get the following error:

“This action does not have any output”. It wont let me insert it in the html.

You need to set the output to use it in an future automation step.

That worked Perfectly! Thank you for your help.

1 Like

Can you explain how you got the output to work? I have 1000 records in a view and would like to get an email every time this view reaches this threshold.

I copied the script but can get the output to work? Any ideas.

Setup a view on your table and get that part setup so that it shows the data exactly the way you want it.

Create a trigger (everyday at this time do this).
Then run a script. Here is an example of mine.

const table = base.getTable(“Dynamic Builder Report”)
const view = table.getView(“Team - Backlog”)
const queryResult = await view.selectRecordsAsync({fields: })
const numRecordsInView = queryResult.records.length
console.log(numRecordsInView )
output.set(‘Team Count’, numRecordsInView);

Then on your email message, plug in that info.

image

Thank you so much! Worked like a charm. That was the missing piece.

this is filler, i used the reply to email feature and my firm stuffed a bunch of legal text in my signature. Wasnt expecting it.

This is the hidden cost of that "respond to a forum post via email" achievement😂

Supreme Lending

Equal Housing Lender

1 Like

OMG lol didn’t expect that!

Can you edit that out?

1 Like

Haha, not a problem.