Skip to content

Commit 3206d0a

Browse files
authored
script.js
1 parent de3ed58 commit 3206d0a

File tree

1 file changed

+14
-0
lines changed
  • Core ServiceNow APIs/GlideRecord/Archiving Old Incident Records to Improve Performance

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var gr = new GlideRecord('incident');
2+
gr.addQuery('state', 7); // Closed
3+
gr.addQuery('active', false);
4+
gr.addQuery('closed_at', '<=', gs.daysAgo(150));
5+
gr.query();
6+
while (gr.next()) {
7+
var ar = new GlideRecord('ar_incident'); //ar_incident is the new table for storing archive data
8+
ar.initialize();
9+
ar.short_description = gr.short_description;
10+
ar.description = gr.description;
11+
// Copy other necessary fields
12+
ar.insert();
13+
gr.deleteRecord(); // deleting from incident table if record in inserted in the archived table
14+
}

0 commit comments

Comments
 (0)