Hi all
I've just got into scripting, and have fallen at the first hurdle.
Hi all
I've just got into scripting, and have fallen at the first hurdle.
To answer my own question for anyone else struggling to work it out. getCellValueAsString() was the solution for me. I don't know if this is the best way of doing it. But this is how you can get whatever field values you need.
I'm printing them here. But you could instead, add each recordDetails to an array.
(disclaimer, I'm not an expert)
Additionally I believe it is preferable to only load the fields you need, to save memory. So you should replace line 2 this code to something like:
Yah, that looks correct.
One tip - I prefer to use .map() .filter() and .reduce() instead of for loops.
I *think* my updated code below should work for you, but you might want to edit/remove the .filter() as it will filter out any non-matched records. I highly doubt any of your records have the name "An example filter string" 😜
let table = base.getTable("Contacts");
let query = await table.selectRecordsAsync({
fields: ["Full Name", "Last Name", "Contact Type"]
});
let recordDetails = query.records
.filter((record) => record.name === "An example filter string")
.map((record) => ({
fullName: record.getCellValueAsString("Full Name"),
lastName: record.getCellValueAsString("Last Name"),
contactType: record.getCellValueAsString("Contact Type")
}));
console.log(recordDetails)
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.