I'm so stumped on this. I've been creating automation to autolink my records, but now I have a messy array field and I cannot for the life of me figure out how to autolink it. I've tried six ways from Sunday using all the code available here.
Here's the code I've been using:
//Define the main table and query
let mainTbl = base.getTable("BIOD CALC");
let mainQuery = await mainTbl.selectRecordsAsync();
//Define link table and query
let linkTbl = base.getTable("ECO ↔ CREDIT");
let linkQuery = await linkTbl.selectRecordsAsync();
//Loop through the records and find the field to update
for (let mainRecord of mainQuery.records) {
let mainId = mainRecord.getCellValue("ECO ↔ CREDIT");
//Loop through linked table and match ID values
for (let linkRecord of linkQuery.records) {
if (linkRecord.getCellValue("eco_id") === mainId) {
//Update field
mainTbl.updateRecordAsync(mainRecord, {
'ECO ↔ CREDIT': [{id: linkRecord.id}]
});
}
}
}Here's some code I tried that didn't work.
let inputConfig = input.config();
console.log(`The value of trim_eco_id is ${inputConfig.trim_eco_id}`);
//Define the main table and query
let mainTbl = base.getTable("BIOD CALC");
let mainQuery = await mainTbl.selectRecordsAsync();
//Define link table and query
let linkTbl = base.getTable("ECO ↔ CREDIT");
let linkQuery = await linkTbl.selectRecordsAsync();
inputConfig['trim_eco_id'].toString().split(',').forEach((s) => {
console.log(s.trim());
//Loop through linked table and match ID values
for (let linkRecord of linkQuery.records) {
if (linkRecord.getCellValue("eco_id") === s.trim()) {
//Update field
mainTbl.updateRecordAsync(mainRecord, {
'ECO ↔ CREDIT': [{id:`${s.trim()}`}]
});
}
}
});
Here's the base I'm trying to link from...

And too..

Totally open to ideas here.



