Help

Re: Delete entries based on condition

Solved
Jump to Solution
191 0
cancel
Showing results for 
Search instead for 
Did you mean: 
cgresse
4 - Data Explorer
4 - Data Explorer

Dear All,

Newbie here! To simplify our current workspace, we would like to duplicate our main base (let's call it A) and delete any entries in the duplicated version (B) with a deadline after June 2023. B will be used as archive for our past work.


Then we would like to run an automation in A to remove any content with the deadline set till June 2023 (so we are only using what is for use " current content")

This is a one-time automation; we do not need it to run multiple times. How can I set up the script for each scenario?

 

Thank you in advance for your support and guidance,

 

Best regards,


Catherine

 

1 Solution

Accepted Solutions
OliCoral
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Catherine,

 

If you need to clean your base, (B or A), one time only, i suggest you to do it manually :

  1. filter on your deadline column to get record older than June 2023
  2. then select those record and delete it.

 

If you need an automation to keep your base up to date, you can chose scheduled trigger then execute a  script like :

 

let table = base.getTable('id_of_your_table')
  let queryResult = await table.selectRecordsAsync({
    fields: ["id_of_your_field_deadline"],
    sorts: []
  })
 
for(let record of queryResult.records) {
  if(record.getCellValue("id_of_your_field_deadline") >=  Date('2023-06-01')){
     await table.deleteRecordAsync(record.id)
  }
}
 
BR

See Solution in Thread

2 Replies 2
OliCoral
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Catherine,

 

If you need to clean your base, (B or A), one time only, i suggest you to do it manually :

  1. filter on your deadline column to get record older than June 2023
  2. then select those record and delete it.

 

If you need an automation to keep your base up to date, you can chose scheduled trigger then execute a  script like :

 

let table = base.getTable('id_of_your_table')
  let queryResult = await table.selectRecordsAsync({
    fields: ["id_of_your_field_deadline"],
    sorts: []
  })
 
for(let record of queryResult.records) {
  if(record.getCellValue("id_of_your_field_deadline") >=  Date('2023-06-01')){
     await table.deleteRecordAsync(record.id)
  }
}
 
BR

Thanks. I ended up doing it manually, as suggested as this was a one-time thing, but good to now how to run a similar script if needed.

 

Many thanks


Catherine