Delete a record by automation script

I would like to build an automation script that deletes the record after 14 days of being done.
Status = done
Table Name = Onboarding Status

You could have a formula field that states how many days a record has been done. Then trigger the automation when the record has been in that state for 14 or more days. If you don’t know how to write an automation script to delete a record, you can buy my automation helper scripts.

IF(
  {Status} = "Done",
  DATETIME_DIFF(
    TODAY(),
    LAST_MODIFIED_TIME({Status}),
    "days"
  )
)
1 Like

hi @Jesus_Yanes,
just building up on @kuovonne’s contribution, after you have created the formula field, you can use it to build the following automation with a script. I am attaching screenshots of the automation below:


Script:

let table = base.getTable("Onboarding Status")

await table.deleteRecordAsync(input.config()['target_record_id']);

Hope this helps!

Website: alessiomonino.com
Calendly: Calendly - Alessio Monino
Email: alessio.monino@gmail.com

Hi Alessio -

This worked, but it automatically deleted the record, instead of respecting the 14 day rule.

IF(
{Status} = “Done”,
DATETIME_DIFF(
TODAY(),
LAST_MODIFIED_TIME({Status}),
“days”
)
)

I named the above formula Column “Record Deletion Formula”

hi @Jesus_Yanes,
understood, in that case you should set the automation in the way I am showing in this screenshot:

Hope this helps!

Website: alessiomonino.com
Calendly: Calendly - Alessio Monino
Email: alessio.monino@gmail.com

This is perfect, thanks Alessio this worked great.

hi @Jesus_Yanes,
sounds great! Feel free to mark my relevant post as the solution so others with your same question can refer back to it in the future

Website: alessiomonino.com
Calendly: Calendly - Alessio Monino
Email: alessio.monino@gmail.com

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.