May 13, 2020 11:58 AM
Hi there, I’m a newbie on airtable… and in the first script I write I encountered a problem and maybe somebody here can help me
let table = base.getTable(“MAIN_TABLE”);
let query = await table.selectRecordsAsync(
{
sort: [{ field: “STRING_FIELD”, direction: ‘desc’ },
{ field: “DATE_FIELD”, direction: ‘desc’ }
]
}
);
for (let registro of query.records) {
// Do some processing…
};
The problem that I have is that the order of the records is always the same, no matter what i write on the sort options invoking the table.selectRecordsAsync function…
There is something that I’m missing here? Anyone has encountered the same problem??
Thanks in advance
May 13, 2020 12:53 PM
Hi @Mario_Cespedes - this is a hard one to spot, but an easy one to fix :slightly_smiling_face:
The keyword is sorts
(plural) not sort
, so something like this:
sorts: [
{field: "Age", direction: "asc"}
]
JB
May 13, 2020 01:08 PM
Thank you @JonathanBowen… really simple