Skip to content

Commit 92838fb

Browse files
authored
Create script.js
1 parent 5752145 commit 92838fb

File tree

1 file changed

+21
-0
lines changed
  • Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
This schedule job will run daily EOD PST time.
3+
This Job will look for articles which have been rated 1 three times and will retire those articles.
4+
5+
*/
6+
var kbFeed = new GlideAggregate('kb_feedback');
7+
kbFeed.addEncodedQuery('rating=1'); // get articles with rating 1.
8+
kbFeed.addAggregate('COUNT', 'article');
9+
kbFeed.groupBy('user');
10+
kbFeed.query();
11+
while (kbFeed.next()) {
12+
13+
if (kbFeed.getAggregate('COUNT', 'article') >= 3) {
14+
var updateArt = new GlideRecord('kb_knowledge');
15+
updateArt.get(kbFeed.article.sys_id);
16+
if (updateArt.workflow_state == 'published') {
17+
updateArt.workflow_state = 'retired';
18+
updateArt.update();
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)