Help

Re: selectRecordsAsync() not working

Solved
Jump to Solution
1959 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Janseman
4 - Data Explorer
4 - Data Explorer

Hi, I am trying to get selectRecordsAsync() to work. I looked up some older posts here and know that the old version was depricated I have to add an array of the field values, however it's still not working.

Here is my code:

async function updateCompanyDomains() {
   let table = base.getTable("MyTableName");
   let queryResult = await table.selectRecordsAsync({fields: table.fields})
}
 
Script runs through without an error, but it queryResult remains empty. If I put a console log after the queryResule line, it's not logged. If I hover over the fields, all the fields of the linked table are shown.
 
For context, in case this could be the root cause: I am in the free trial.
 
Any help is highly appreciated, thanks.

 

1 Solution

Accepted Solutions
Jack_Manuel
7 - App Architect
7 - App Architect

As your function is async you need to await the call to it.

async function updateCompanyDomains() {
    let table = base.getTable("MyTableName");
    let queryResult = await table.selectRecordsAsync({fields: table.fields});
    console.log(queryResult)
}

await updateCompanyDomains()

See Solution in Thread

3 Replies 3
Jack_Manuel
7 - App Architect
7 - App Architect

As your function is async you need to await the call to it.

async function updateCompanyDomains() {
    let table = base.getTable("MyTableName");
    let queryResult = await table.selectRecordsAsync({fields: table.fields});
    console.log(queryResult)
}

await updateCompanyDomains()
Janseman
4 - Data Explorer
4 - Data Explorer

Thanks so much, Jack_Manuel, that did the trick. Guess a Java Script basic - must refresh my JS brain cells.

Jack_Manuel
7 - App Architect
7 - App Architect

It happens to the best of us!