diff --git a/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/README.md b/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/README.md new file mode 100644 index 0000000000..5197670f3f --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/README.md @@ -0,0 +1,3 @@ +**How to use** +1. This scheduled job will run according to the frequency, mostly daily EOD. +2. This will look for articles rated one, 3 or more than 3 times and will retire them. diff --git a/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js b/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js new file mode 100644 index 0000000000..7114ae7078 --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles/script.js @@ -0,0 +1,21 @@ +/* +This schedule job will run daily EOD PST time. +This Job will look for articles which have been rated 1 three times and will retire those articles. + +*/ +var kbFeed = new GlideAggregate('kb_feedback'); +kbFeed.addEncodedQuery('rating=1'); // get articles with rating 1. +kbFeed.addAggregate('COUNT', 'article'); +kbFeed.groupBy('article'); +kbFeed.query(); +while (kbFeed.next()) { + + if (kbFeed.getAggregate('COUNT', 'article') >= 3) { // check if article is rated 1 three times + var updateArt = new GlideRecord('kb_knowledge'); + updateArt.get(kbFeed.article.sys_id); + if (updateArt.workflow_state == 'published') { //check if article is published + updateArt.workflow_state = 'retired'; // retire the article + updateArt.update(); + } + } +}