Hello friends,
I am looking for an automation/script that does the following.
1. When the field 'Start date' is updated in a record in the table called 'Projects'
... I would like...
this new 'Start Date' to replace the current date on a field called 'Deadline' in a record which is always called 'Project Start Date' in a linked record field of the triggering record called 'Tasks'.
If it helps at all:
- the linked record field 'Tasks' is linked to the table called 'Tasks'
- The record which I want to change called 'Project Start Date' sits under a field called 'Task', in the 'Tasks' table
I have no experience in scripting, Gemini provided me with the following, but it doesn't appear to be working
Note: My trigger is When a record is updated - "Start date" - on the "Projects" table:
async function updateLinkedRecordDeadline(record) {
const linkedRecords = record.getCellValue('Tasks');
// Iterate through each linked record
for (const linkedRecord of linkedRecords) {
if (linkedRecord.getCellValue('Task') === 'Project Start Date') {
// Update the "Deadline" field
await base.getTable('Tasks').updateRecordAsync(linkedRecord.id, {
Deadline: record.getCellValue('Start Date')
});
console.log('Deadline of "Project Start Date" task updated successfully.');
break; // Exit the loop after updating the first match
}
}
}
Thanks so much for your help!