Nov 09, 2023 04:48 AM
Nov 09, 2023 07:32 PM
Hello there. I'm not sure if you trying to get a match between the recordID from the input and the recordID in the table called "Matsalen", but in any case, I tried to figure out this solution
let table = base.getTable("YOUR_TABLE_NAME");
let id = input.config().recordID.toString()
let query = await table.selectRecordsAsync({
fields: ["Field1", "Field2",...,"Fieldn","RecordID"], //you should select all the records to display after the recordID match
})
let array = []
//Getting all the records from the table and pushing them into an object array
for (let record of query.records){
array.push(
{
"id": record.getCellValueAsString("RecordID")
}
)
}
//Loop through the array to match the input recordID with the recordID in the table
for (var i=0; i<array.length;i++){
if(array[i].id === id){
console.log(`The ID of the input is ${id} and
it belongs to the record
${query.getRecord(id).getCellValue("Fieldn")} //Here you can choose the field or fields you would like to display with multiple getCellValue
`)
}
}
Let me know if it's useful for your case.
Regards.
Nov 10, 2023 01:00 AM
Thanks @Richard_Quintan
I solved it like this, the problem was it didn't pic the right recordID, but now it works on 1 automation
But I have now a problem when the variable is a "list of AirtableIDs" since its going to be a scheduled automation, but its always just going to be 1 recordID, but in the variable I can't choose just 1. And this code gives me syntax error. Do you know what I need to do in the script when there is a "list" of Airtable IDs but is always just going to be one?
You see the difference in the variable of the recordID on the left.
Nov 29, 2023 06:30 PM
Hello there @Jesper_Holmstro and sorry for the delay in responding. As I'm watching, I think that you can't match with the exact ID due to the wrong usage of the function selectRecordsAsync(). In your particular case, you should do something like this
let table = base.getTable("YOUR_TABLE_NAME");
let query = await table.selectRecordsAsync({
fields: ["Field1", "Field2",...,"Fieldn","RecordID"], //you should select all the records you want to retrieve, even the recordID field
})
To retrieve the recordID field correctly, you should create a field type formula and then write the formula