Skip to main content
Solved

Delete a record by automation script

  • April 4, 2022
  • 6 replies
  • 149 views

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

Best answer by Alessio_Monino

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

6 replies

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • April 4, 2022

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"
  )
)

Forum|alt.badge.img+11
  • Participating Frequently
  • Answer
  • April 5, 2022

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


  • Author
  • Participating Frequently
  • April 5, 2022

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”


Forum|alt.badge.img+11
  • Participating Frequently
  • April 5, 2022

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


  • Author
  • Participating Frequently
  • April 5, 2022

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.


Forum|alt.badge.img+11
  • Participating Frequently
  • April 6, 2022

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