Skip to content

Commit 31b8a13

Browse files
Create README.md
1 parent f51aebf commit 31b8a13

File tree

1 file changed

+32
-0
lines changed
  • Server-Side Components/Script Includes/Dynamic Record Archiving

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Dynamic Record Archiving Logic
2+
3+
## Overview
4+
This snippet provides a reusable logic to archive or flag records in ServiceNow that are older than a specified threshold. It helps maintain data hygiene, improve performance, and support compliance with data retention policies.
5+
6+
You can choose between two modes:
7+
- **Flag Mode**: Marks records as archived using a custom field (`u_archived`).
8+
- **Move Mode**: Moves records to a corresponding archive table (e.g., `incident_archive`) and deletes the original.
9+
10+
---
11+
12+
## Use Case
13+
- Archive incidents older than 1 year.
14+
- Clean up old tasks, requests, or custom records.
15+
- Automate data lifecycle management via Scheduled Jobs.
16+
17+
---
18+
19+
## Parameters
20+
| Parameter | Description |
21+
|---------------------|-----------------------------------------------------------------------------|
22+
| `tableName` | Name of the table to archive (e.g., `incident`) |
23+
| `dateField` | Date field to filter by (e.g., `opened_at`, `created_on`) |
24+
| `archiveThresholdDays` | Number of days before today to consider for archiving (e.g., `365`) |
25+
| `archiveMode` | `'flag'` to mark records, `'move'` to transfer to archive table |
26+
27+
---
28+
29+
## Example Usage
30+
```javascript
31+
var archiver = new RecordArchiver('incident', 'opened_at', 365, 'flag');
32+
archiver.archiveRecords();

0 commit comments

Comments
 (0)