Skip to main content
Solved

How to use the ReadonlyArray.find method

  • November 2, 2022
  • 1 reply
  • 13 views

Hi.

Imagine that I have this:

let result = await table.selectRecordsAsync({fields: table.fields});

Navigating the API, I saw we can do this:

result.records.find(…)

but I cant’ fin any example. Can you explain how to use it?

Thanks in advance.

Best answer by Rupert_Hoffsch1

Hi @Guillermo_Ramos_Rui1,

so records.find() is simply using the Find() Javascript array method on the records array. Please read about find() here: Array.prototype.find() - JavaScript | MDN

Find requires a testing function inside and will give you the first array item that satisfied the function.

So something like: result.records.find(rec => rec.getCellValue("Name") === "Bob")

1 reply

Rupert_Hoffsch1
Forum|alt.badge.img+21

Hi @Guillermo_Ramos_Rui1,

so records.find() is simply using the Find() Javascript array method on the records array. Please read about find() here: Array.prototype.find() - JavaScript | MDN

Find requires a testing function inside and will give you the first array item that satisfied the function.

So something like: result.records.find(rec => rec.getCellValue("Name") === "Bob")