Skip to content

Commit 91d5840

Browse files
authored
Merge pull request #2168 from Soumyadeep10/Hacktober-2025-8th_bRanch
Publish Retired Knowledge articles again
2 parents 2f5b8cd + 1f10ac4 commit 91d5840

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
**UI Action**:
2+
Publish a Retired Knowledge Article again after it is already retired.
3+
4+
**How it works:**
5+
1. The code finds existing articles in the Knowledge base that share the same Article ID but are not the current article and are 'retired'.
6+
2. It updates the workflow state of these found articles to 'outdated'.
7+
3. For the current article, it sets the workflow_state to 'pubblished', records the current date and updates the 'published' field with the date.
8+
4. It also removes the pre-existing 'retired' date from the 'retired' field.
9+
5. It redirects the user to the updated current record.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var kbArticle = new GlideRecord('kb_knowledge');
2+
kbArticle.setWorkflow(false);
3+
kbArticle.addQuery('article_id', current.article_id);
4+
kbArticle.addQuery('sys_id', "!=", current.sys_id); //articles that are not the current one
5+
kbArticle.addQuery('workflow_state', 'retired');
6+
kbArticle.query();
7+
while (kbArticle.next()) {
8+
kbArticle.workflow_state = 'outdated'; //setting the articles as outdated
9+
kbArticle.update();
10+
}
11+
current.workflow_state = 'published'; //publishing retired kb article again
12+
current.published = new GlideDate();
13+
current.retired = ""; //clearing retired field value
14+
current.update();
15+
action.setRedirectURL(current);

0 commit comments

Comments
 (0)