Jun 26, 2023 10:14 PM
I've posted the code below.
What am I missing here? I'm trying to update the field 'Parent' with the Parent's record ID when creating records in the 'Child' table, but it says that it cannot accept the value provided...even though it's an array of recordIDs (in this case, just a single one).
I even have a log showing that it provides the correct record ID, which it does.
I appreciate any help anyone is willing to offer.
let sourceTable = base.getTable("Parent");
let destinationTable = base.getTable("Child");
let query = await sourceTable.selectRecordsAsync();
let checkedRecords = query.records.filter(record => record.getCellValue("Transfer"));
let recordsToCreate = checkedRecords.map(record => {
// Get the record ID from the source record
let sourceRecordId = record.id;
return {
fields: {
'Name': record.getCellValue('Name'),
'Parent': [sourceRecordId] // Pass as an array
}
}
});
while (recordsToCreate.length > 0) {
for (let record of recordsToCreate.slice(0, 50)) {
console.log(`Creating record with sourceRecordId: ${record.fields['Parent'][0]}`);
}
await destinationTable.createRecordsAsync(recordsToCreate.slice(0, 50));
recordsToCreate = recordsToCreate.slice(50);
}
Solved! Go to Solution.
Jun 27, 2023 03:07 AM
I think the expected format's `[{id: RECORD_ID}]`, so perhaps try:
'Parent': [{id: sourceRecordId}]
Jun 27, 2023 03:07 AM
I think the expected format's `[{id: RECORD_ID}]`, so perhaps try:
'Parent': [{id: sourceRecordId}]
Jun 27, 2023 02:33 PM
That was exactly it. I knew it was something simple like that. Thank you so much.