Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Feb 10, 2024 11:10 PM
below is my code but the console log doesnt give me the number of records:
async function loadRecordsAndLogCount() {
console.log("Script started - attempting to fetch records.");
try {
const table = base.getTable("Tasks");
console.log("Table 'Tasks' successfully accessed.");
// Correctly await the asynchronous call to selectRecordsAsync
const query = await table.selectRecordsAsync({
fields: ["Predecessors", "Tasks", "Next task"]
});
// Log the total number of records fetched
console.log("Records selected, total:", query.records.length);
} catch (error) {
// Log any errors encountered during the execution
console.error("Script encountered an error:", error);
}
}
// Make sure to call the async function and properly handle any uncaught errors
loadRecordsAndLogCount().catch(error => console.error("Unhandled script error:", error));
Solved! Go to Solution.
Feb 11, 2024 01:51 AM
Add an await to your last line so that it's
await loadRecordsAndLogCount().catch(error => console.error("Unhandled script error:", error));
Should work fine with that change
Feb 11, 2024 01:51 AM
Add an await to your last line so that it's
await loadRecordsAndLogCount().catch(error => console.error("Unhandled script error:", error));
Should work fine with that change
Feb 11, 2024 07:26 AM
Awesome this worked!! Thank you so much!