How to remove KB articles which are 5 years old, i tried Flow Designer but no use. Can you please help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 09:42 AM
Im trying to remove kb articles which are published more than 5 years, using flow designer. but no luck it is not picking up anything.
this is the trigger im using,
as part of developing im trying to change to valid to certain date.
Please give me any suggestions if we can try another way.
- Labels:
-
flow designer
-
Knowledge Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 09:52 AM
Use Background script to delete Knowledge article
delkb();
function delkb() {
var gr = new GlideRecord("kb_knowledge");
gr.addEncodedQuery(''); // Enter query from filter used in kb_knowledge
gr.setWorkflow(false);
gr.query();
while (gr.next()) {
gr.deleteRecord();
}
}
Please mak thisas correct if this script is helpful to you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 12:11 PM
this should run daily. check for 5 years kb and delete it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 12:36 PM
You could use something similar to this in a scheduled job script execution:
var kbArticle = new GlideRecord('kb_knowledge');
kbArticle.addQuery('workflow_state', 'published');
kbArticle.query();
while (kbArticle.next()) {
var diffDays = gs.dateDiff(kbArticle.u_review_date, gs.now(), true) / 86400;
gs.log(kbArticle.number + "datediff" + diffDays);
if (diffDays >= 365 && diffDays < 366) { //* introduce a little flexibility of diffDays result to allow for fractional calculations
gs.eventQueue('unchc.notify.author.365', kbArticle, kbArticle.author, kbArticle.kb_knowledge_base.owner);
}
}
Just modify the diffDays field check to suit and amount to be >= 5 years worth, and rather than trigger an email, update the records or delete them

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 12:54 PM