Automate Appending Linked Records

Hello, I am trying to create an automation for assign shifts to contractors.

Here is the current structure:

  1. Look for checkbox = true as trigger
  2. Find records in “Scheduling” where Name from record in step one is in “Offered to” linked record field.
  3. Add Contractor to “Confirmed” linked record field in all records from step 2.

Step 1 and 2 function just fine. I know that Step 3 will require a script.

I used a few of the previous help posts for this subject on the forum to piece together a script that I believed would get the job done.

Here is the script:

let inputConfig = input.config();
let newRecord = inputConfig.newRecord;
let records = inputConfig.listOfRecords;
let table = base.getTable(“Scheduling”);
let queryResult = await table.selectRecordsAsync({fields: [“Confirmed”]});

for (let record of records) {
let recordObj = queryResult.getRecord(record)
await table.updateRecordAsync(recordObj, {
‘Confirmed’: [
…recordObj.getCellValue(‘Confirmed’),
{id: newRecord}
]
})
}

I get the following error when running:

TypeError: recordObj.getCellValue is not a function or its return value is not iterable

The value of the the “Confirmed” field at the moment is null (it is blank). I know this likely has something to do with it but I cannot figure out what needs to change.

The script is pulling in the correct values for “newRecord” (the record that triggered the automation) and “records” (all records that need to be updated from step 2).

I attempted to query the “record” string inside of the loop after reading that .getCellValue needs the record object to execute, but this did not help.

Hey man, if you could invite me to your base I could help you troubleshoot this