You can delete old attachment versions using this script. Using fields to specify the attachment versions you'd like to keep and the minimum age they need to be, you can run this script to identify and remove old attachment versions.

Since old versions are kept each time a new version is saved, this can free up a lot of space.

To use this script, follow these steps:

  1. In CQL Query, enter a query to select attachments.

    Select Show Examples to see example queries to enter here.
  2. Specify the minimum age of attachment versions you want to delete in *Attachment Age Version*.
  3. Specify the minimum number to keep regardless of the age selected in *Minimum Versions to Keep*. Blank retains only the current version.

    If there is an overlap between the values, the Minimum Versions to Keep field takes precedence over the Attachment Age Version field.
    Example: There are 10 attachment versions and all are older than 1 year. If the script is configured to delete attachments older than 6 months and keep 3 at minimum, v8-v10 are kept to abide by the minimum number of versions to keep field and v1-v7 are deleted.

    Additionally, when a Minimum Number of Versions to Keep is entered, only the latest versions are kept.
    Example: If there are v1-v5 and 2 are selected to keep at a minimum, v4 and v5 (the current version) are kept.

  4. Select Run.
    You can select Preview instead of Run to view changes before implementing them.
    Once you select Run, the Results of the script appear.