How to Automatically Archive Old Data

(info) Starting archiving tasks from a calculation flow is available as of the Mai Tai release.

Scenario

A customer has several millions of rows in the Product Competition table (this can easily happen when loading data from companies who gather data from many competitors). But you're using only data from the last month in this table.

You can use the Archiving utility (Configuration > System > Import / Export / Archiving) but this is a manual process. How to do this automatically at regular intervals?

Solution

  1. Create an "Archiving Template" – i.e. prepare the Archiving process (the same as manual), but do not run it.
  2. Create a Calculation Flow Formula (CFF) which will execute the Archiving process.
  3. Create a Calculation Flow – i.e. set the scheduler to run the CFF every month. 
Example of the Calculation Flow Formula
def date = (new Date()).format("yyyy-MM-dd'T'HH:mm:ss")
def archiveActionSourceTemplate = "Template_ArchiveCompetitionData" //label of the manually created Archiving process
def archiveActionResultName = "ArchiveCompetitionData_" + date

actionBuilder
  .addExportAction(archiveActionResultName)   
    .doArchive(archiveActionSourceTemplate)

Example

The second item in the table shows the Template, the third one shows the result.

This is the configuration of the Template in detail: