Help

Re: Count Number of Records in a view

5597 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Brandon_Roloff
5 - Automation Enthusiast
5 - Automation Enthusiast

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.

12 Replies 12

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 )
Brandon_Roloff
5 - Automation Enthusiast
5 - Automation Enthusiast

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.

Brandon_Roloff
5 - Automation Enthusiast
5 - Automation Enthusiast

That worked Perfectly! Thank you for your help.

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

Ron_Garcia
5 - Automation Enthusiast
5 - Automation Enthusiast

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