Dec 15, 2024 10:11 PM
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!
Solved! Go to Solution.
Dec 16, 2024 03:26 AM
Hey @James_Davis,
Why don't you use a lookup field with that date on your project table form the tasks tables? The automation will do the replacement.
Scripting is cool and handle, but keep in mind that it decreases the low-code principle, making it less manageable for the team...
Thanks
Dimitris Goudis (3Nuggets)
Dec 16, 2024 03:26 AM
Hey @James_Davis,
Why don't you use a lookup field with that date on your project table form the tasks tables? The automation will do the replacement.
Scripting is cool and handle, but keep in mind that it decreases the low-code principle, making it less manageable for the team...
Thanks
Dimitris Goudis (3Nuggets)
Dec 17, 2024 09:36 PM
Thanks for this, Dimitris. I used your idea with a lookup + automation, but also included a few other fields/formulas that got things just right. I appreciate your help!