Retire translated versions when english article is retired
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I created a Business Rule that retires translated articles when the English version is retired. It works fine if there's a translation for the same version of the English article.
But here's the problem:
If I retire the latest English version (like v3) and it doesn't have a translation, the rule doesn't retire older translated versions (like v1 or v2). Those older translations stay active.
What I need is:
Whenever I retire the latest English version, all translations from any version should be retired — even if they were created for older versions.
Below is the business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago - last edited 6 hours ago
You need to Identify all English versions of the same article, and then retire translations of all those versions.
Below updated Script might work for your use case:
(function executeRule(current, previous /*null when async*/) {
var englishVersions = new GlideRecord('kb_knowledge');
englishVersions.addQuery('article_number', current.number);
englishVersions.addQuery('language', 'en');
englishVersions.query();
var englishIds = [];
while (englishVersions.next()) {
englishIds.push(englishVersions.sys_id.toString());
}
// Find and retire all translations linked to any of those English versions
var translations = new GlideRecord('kb_knowledge');
translations.addQuery('translated_from', 'IN', englishIds);
translations.addQuery('workflow_state', '!=', 'retired');
translations.query();
while (translations.next()) {
translations.workflow_state = 'retired';
translations.update();
}
})();
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.