diff --git a/Client-Side Components/UI Actions/Publish a Retired Knowledge Article again/README.md b/Client-Side Components/UI Actions/Publish a Retired Knowledge Article again/README.md new file mode 100644 index 0000000000..c53505944e --- /dev/null +++ b/Client-Side Components/UI Actions/Publish a Retired Knowledge Article again/README.md @@ -0,0 +1,9 @@ +**UI Action**: +Publish a Retired Knowledge Article again after it is already retired. + +**How it works:** +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'. +2. It updates the workflow state of these found articles to 'outdated'. +3. For the current article, it sets the workflow_state to 'pubblished', records the current date and updates the 'published' field with the date. +4. It also removes the pre-existing 'retired' date from the 'retired' field. +5. It redirects the user to the updated current record. diff --git a/Client-Side Components/UI Actions/Publish a Retired Knowledge Article again/publishretiredkb.js b/Client-Side Components/UI Actions/Publish a Retired Knowledge Article again/publishretiredkb.js new file mode 100644 index 0000000000..81d31b78b7 --- /dev/null +++ b/Client-Side Components/UI Actions/Publish a Retired Knowledge Article again/publishretiredkb.js @@ -0,0 +1,15 @@ +var kbArticle = new GlideRecord('kb_knowledge'); +kbArticle.setWorkflow(false); +kbArticle.addQuery('article_id', current.article_id); +kbArticle.addQuery('sys_id', "!=", current.sys_id); //articles that are not the current one +kbArticle.addQuery('workflow_state', 'retired'); +kbArticle.query(); +while (kbArticle.next()) { + kbArticle.workflow_state = 'outdated'; //setting the articles as outdated + kbArticle.update(); +} +current.workflow_state = 'published'; //publishing retired kb article again +current.published = new GlideDate(); +current.retired = ""; //clearing retired field value +current.update(); +action.setRedirectURL(current);