Help

Re: Help with a script/auto that will update a field of a linked record based on a static named reco

Solved
Jump to Solution
28 0
cancel
Showing results for 
Search instead for 
Did you mean: 
James_Davis
5 - Automation Enthusiast
5 - Automation Enthusiast

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!

 

1 Solution

Accepted Solutions

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)

See Solution in Thread

2 Replies 2

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)

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!