Equivalent of a "find records" step in scripting app that allows more than 100 records to be found?

I have an automation that I need to count all records that meet a certain criteria. The number of records that meet this criteria exceeds 100, so the find records tool isn’t useful. There is a scripting block in the automation and I would like to count them there, but I’m not seeing an easy way to do this.

I only need the step to return the count of records that meet the criteria, not the actual records themselves. Has anybody done something similar?

Ideally I could make a view with the criteria filtered and then have the scripting step return the number of records in the view, but I don’t see any documentation for a function to fetch record count within a view in the API docs. Also don’t see a way to use selectRecordsAsync with an offset to capture all records that meet a criteria instead of just the 100 allowed by the function as it currently exists. Any thoughts?

You have the right idea. Loading a query from a view will return an array of records. Like any array in javascript, doing array.length will give you the total number of items in that array, which in this case would be the count of records in that view.

let table = base.getTable("Table");
let view = table.getView("Criteria");
let query = await view.selectRecordsAsync({fields: []})

let records = query.records
let count = records.length
1 Like

Read to the end of the thread to get how to use output.set so you can use the count in a future automation step.

1 Like

Thank you! This is perfect.

1 Like

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.