Dear Community,
I want to automatically link records by linking incomming subscriptions (Table called EmailSubscriptions) to certain dogbreeds (!Hondenrassen). I need to match based on a unique id. This ID is in (EmailSubscriptions the “Kind”) and in the Table !Hondentassen also “Kind”. I want to link thise two automatically when a record enters a view. Using the a automation to run the script. I made this script based on some community scripts but it doesn’t seems to work. Can anyone help?
/Define the !Hondenrassen table and query
let cmpTbl = base.getTable(“!Hondenrassen”);
let cmpQuery = await cmpTbl.selectRecordsAsync();
//Define EmailSubsciptions table and query
let cntTbl = base.getTable(“Email”Subscriptions);
let cntQuery = await cntTbl.selectRecordsAsync();
//Loop through the records and find the Kind
for (let record of cmpQuery.records) {
let cmpid = record.getCellValue(“Kind”);
//Loop through linked table and match ID Values
for (let cntRecord of cntQuery.records) {
if (cntRecord.getCellValue(“Kind”) === cmpid) {
//Update field
cmpTbl.updateRecordAsync(record, {
“Kind”: b{id: cntRecord.id}]
});
}
}
}