Skip to content

Commit 5746c80

Browse files
authored
Create Remove_Inactive_users_from_Active_tickets.js
1 parent 44d4683 commit 5746c80

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var arr =[];
2+
var gr = new GlideRecord('sys_user');
3+
gr.addQuery('active',false);
4+
gr.query();
5+
//gs.log('step 1');
6+
while(gr.next()){
7+
arr.push(gr.getValue('sys_id') + ''); //query inactive users and push them to the array
8+
}
9+
for(var i=0; i < arr.length; i++){
10+
var inc = new GlideRecord('incident');
11+
inc.addQuery('active',true);
12+
inc.addQuery('state','!=',6);
13+
inc.addQuery('state','!=',3);
14+
inc.addQuery('state','!=',7);
15+
inc.addQuery('assigned_to',arr[i]);
16+
inc.query();
17+
while(inc.next()){ //query active incidents with state is not 6,3,7
18+
inc.assigned_to = '';//set the assign to empty
19+
inc.update();
20+
gs.eventQueue('incident.assignedto.inactive',inc,gs.getUserName(),gs.getUserName()); //trigger the notification event for Assignment group Manager
21+
}
22+
}

0 commit comments

Comments
 (0)