I realize this is constantly asked in variations but I cannot find a solution to the issue.
Most auto-linking scripts replace the contents of the field, in lieu of appending the new linked record to the field.
I’ve attempted to concatenate the array of IDs, but that throws an error on the field write.
//Define the company table and query
let cmpTbl = base.getTable("Speaker Calls");
let cmpQuery = await cmpTbl.selectRecordsAsync();
//Define contact table and query
let cntTbl = base.getTable("All Interested");
let cntQuery = await cntTbl.selectRecordsAsync();
//Loop through the records and find the Contact ID
for (let record of cmpQuery.records) {
let cmpid = record.getCellValue("Campaign Name");
let cmpid2 = record.getCellValueAsString("mem");
let cmptest = record.getCellValue("Scouted");
console.log(cmpid2);
//Loop through linked table and match ID values
for (let cntRecord of cntQuery.records) {
if (cntRecord.getCellValue("Campaign Name") === cmpid) {
//Update field
let cntid2 = {id: cntRecord.id};
let cntid3 = cntRecord.getCellValueAsString("Member ID");
console.log(cntid3);
//Update field
let full = cmpid2 + ", " + cntid3;
console.log(full);
cmpTbl.updateRecordAsync(record, {
'Scouted': :full]
});
}
}
}```