FAQ
How can we help?
Full Site Search

How to Automatically Delete Records That Are Over X Days Old?

Suppose you must automatically delete entries from your system after a certain period due to specific cybersecurity regulations. In that case, you can consider adding a script to your database to help you automatically delete records that are over x days old on a specified sheet.

Please follow the steps below:

Step 1: Open the Javascript Workflow Editor

Right-click on any sheet name and select Javascript Workflow.

Step 2: Switch to Daily Workflow

Step 3: Specify the Sheet Path For Your Workflow

Suppose the sheet path where you want to automatically delete records that are over 10 days old is:

https://www.ragic.com/accountname/tabname/1?PAGEID=wSM (ignore the ?PAGEID=wSM part), enter the following in the script:

db.deleteOldRecords("/tabname/1", 10);

Be sure to save your changes before exiting. If you want to change the number of days, modify the number in db.deleteOldRecords('/tabname/1', X). For example, if you want a record to be deleted when it is 20 days old, you should enter:

db.deleteOldRecords("/tabname/1",20);
If you need to include the exact time of execution, add true as the third parameter:
db.deleteOldRecords("/tabname/1", 10, true); 

If the script runs on July 11 at 21:00:00, it will delete records created before July 1 at 21:00:00.

Note:

1. This workflow is only for deleted records from a single sheet. It does not delete records from the entire database.

2. To ensure the record is indeed deleted, the script will permanently remove the record. It will not be moved to the Recycle Bin, which means it cannot be recovered. Please make sure you absolutely need this feature before writing the related script.

3. This method can delete up to 500 records per execution.

    Start Ragic for free

    Sign up with Google

    北京立即科技有限公司
    京ICP备2022003680号
    Terms of Service | Privacy Policy