Skip to content

Commit d310046

Browse files
authored
Create Stale Tasks Auto-Close.js
The script identifies tasks that haven’t been updated for a set period, sends reminder notifications to assigned users, and, if still inactive after additional time, automatically closes them. This helps keep task lists current and reduces manual follow-ups.
1 parent 20569ab commit d310046

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var staleDays = 7;
2+
var closeDays = 14;
3+
var reminderGR = new GlideRecord('task');
4+
reminderGR.addActiveQuery();
5+
reminderGR.addEncodedQuery('sys_updated_onRELATIVELE@dayofweek@ago@' + staleDays);
6+
reminderGR.query();
7+
while (reminderGR.next()) {
8+
gs.eventQueue('task.reminder', reminderGR, reminderGR.assigned_to, staleDays + ' days without update.');
9+
}
10+
11+
var closeGR = new GlideRecord('task');
12+
closeGR.addActiveQuery();
13+
closeGR.addEncodedQuery('sys_updated_onRELATIVELE@dayofweek@ago@' + closeDays);
14+
closeGR.query();
15+
while (closeGR.next()) {
16+
closeGR.state = 3; // Closed
17+
closeGR.update();
18+
}

0 commit comments

Comments
 (0)