Continuing the discussion from Script Block - Linked Record Issue:
Hi Just wondering if this is the same issue. I have a linked record to another table. I’m trying to update this via a script. If I update a non-linked record it outputs as expected but seems unable to update the linked record. The code is as below:
// set the table
let dashboardTbl = base.getTable("Coaching - meetings");
// get the table records
let dashboarddate = await dashboardTbl.selectRecordsAsync();
// loop through the records
for (let record of dashboarddate.records) {
// get date from field value "Date"
let dashboarddate = record.getCellValue("Date");
// turn it into a date object
dashboarddate = new Date(dashboarddate);
//get year from date
let dashboardyear = dashboarddate.toLocaleString('en-GB', {year: 'numeric'});
//get month from date
let dashboardmonth = dashboarddate.toLocaleString('en-GB', {month: 'long'});
// only run on records which no linked dashboard data
if (record.getCellValue('Dashboard') === null) {
output.text(`Copying date for record ${record.name} ${dashboardyear}${dashboardmonth}`)
// update the Dashboard value with year followed by month
dashboardTbl.updateRecordAsync(record, {
//Test: dashboardyear + dashboardmonth
Dashboard: dashboardyear + dashboardmonth
})
}
}