Create an archive rule

The System Archiving application includes several sample archive rules that illustrate the archive features. Each archive rule provides an estimate of the number of records the rule affects.

Before you begin

Role required: admin

About this task

The sample archive rules are not intended as best practice and are inactive by default.
Note: If you want to archive email, activate the Email retention plugin and use the archive and destruction rules that come with the plugin. Do not use the archive feature to create your own archiving rules on the Email table.

Procedure

  1. Navigate to System Archiving > Archive Rules.
  2. Click New.
    Archive Rule form
  3. Fill in the fields as appropriate.
    Table 1. Archive Rule form
    Field Description
    Name Required. Enter a unique name that identifies the rule. Since this is the display field for archive rules, references to archive rules display the name you enter here.
    Table Required. Select the table containing records to archive. There can only be one archive rule per table. If there is an existing archive rule for a table, the table no longer appears as an option on the archive rule table list.
    Active Select this check box to enable the archive rule. Clear the check box to disable the rule. ServiceNow recommends leaving your archive rules inactive until you calculate an estimate of the number of records the rule affects and verify that rule behaves as expected.
    Description Enter a description of the archive rule.
    Parent Select an existing archive rule on which this rule depends to run. This archive rule only runs when the parent rule also runs.
    Conditions Select the fields and values that must be true in order for the archive rule to run. Typically, you would archive inactive records older than a certain date.
  4. Click Submit.

What to do next

After verifying that the archive rule is selecting records as expected, activate the archive rule.

If you do not want to wait for the scheduled job to run the archive rule, you can manually start the archive rule by clicking Run Archive Now.

Archive related records

Use the Archive Related Records related list to add related records to the archive rule.

  1. Navigate to System Archiving > Archive Rules.
  2. Select the appropriate archive rule.
  3. From the Archive Related Records related list, click New.
    Archive Related Records form
  4. Fill in the Archive Related Records form.
    Table 2. Archive Related Records form
    Field Description
    Archive map Displays the archive rule to which the related records apply.
    Action
    Select the action you want the archive rule to take on related records. Choices include:
    • Archive: archive records that reference the archived record.
    • Clear: remove the reference to the archived record. The record no longer references the archived record and does not appear as a related record in future archives.
    • Delete: delete records that reference the archived record.
    Reference
    Select the relationship of the records you want to apply an action to. The Reference field lists all relations that currently exist for the table being referenced. There are two types of possible relations.
    • Another table has a reference field calling the archived table. For example, if you are archiving problem records, there is a Problem ID field in the Incident table that references the related problem records.
      • The Archive action archives the related record in addition to the primary record. For example, if you select the Problem in Incident reference, the related record rule also archives any incident record that references an archived problem.
      • The Clear action removes the reference to the primary record. For example, if you select the Problem in Incident reference, the related record rule updates any incident record with a reference to the archived problem record by clearing the reference. If the reference is a many-to-many relationship, the related record rule deletes the reference instead of clearing the reference.
      • The Delete action deletes any record that references the primary record. For example, if you select the Problem in Incident reference, the related record rule deletes any incident record that references the archived problem record.
    • Another table has a Document ID field which might point to the archived table. For example, if you are archiving problem records, there is a sys ID field in the Attachments table that may reference the problem record. The list indicates document ID relationships by displaying an asterisk (*) character at the end of the selection name.
      • The Archive action updates the Document ID of the related record to point to the archived table. For example, if you select the Table sys ID Attachment(sys_attachment)* reference, the related record rule updates the attachment record to change the Document ID to refer to the archived table record.
      • The Clear action updates the Document ID of the related record to point to the archived table.
      • The Delete action deletes any record that references the primary record. For example, if you select the Table sys ID Attachment(sys_attachment)* reference, the related record rule deletes any attachment record that references the archived primary record.
    Reference table Displays the table where the rule looks for related records.
    Reference element Displays the reference field or Document ID the rule queries for.
    Reference table rule Select an existing archive rule that applies to the related records you are archiving. For example, if you already have an archive rule for the Incident table, you can select the existing Incident table rule when archiving records related to incidents records.
  5. Click Submit.

Verify the number of records affected

Each archive rule provides an estimate of the number of records the rule affects.

About this task

This estimate only includes primary records and excludes any related records added to the archive rule. The estimate helps you determine if the archive rule affects the number of records you expect it to. If the estimate is too high or low, change the archive rule conditions and then click the Recalculate Estimate related link.

Procedure

  1. Navigate to System Archiving > Archive Rules.
  2. Select the archive rule you want to estimate records for.
  3. Click the Recalculate Estimate related link.

Setting the language of archived strings

On internationalized instances, the archive process uses the language of the SYSTEM user to select the display value strings.

If there is no SYSTEM user, the instance uses the default language setting to select the display value strings. You can either create a SYSTEM user with a specific language setting or set the system default language to select the language of archived strings.
Figure 1. Sample Archive Displayed in French