Is there a way to restrict KB article to only published versions should be visible on portal ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 2 hours ago
Hi All,
It appears that on the service portal view of the knowledge base non approved versions appear as an updated version available to view in the service portal view of the knowledge base. Is there a way to restrict this to only published versions? As per shown in the below image 13.02 is the updated version but in draft state meanwhile 13.0 is published version. I need to show only publish version of KB and unpublished version of KB article should not be visible. Please let me know how can I achieve it ?
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
hey @1_DipikaD
In Service Portal, the knowledge article shows An updated version of this article is available even when the newer version is still in Draft state.
Example:
Version 13.0 - Published
Version 13.02 - Draft
Even though 13.02 is not approved, the portal still shows it as an updated version.
Root Cause
The Knowledge Article widget uses the following logic:
kbViewModel.getLatestAccessibleVersionFromId()
This method returns the latest accessible version, not the latest published version.
So if the logged-in user has access to Draft articles (admin, kb_writer, etc.), the Draft version is treated as the latest one and triggers the banner.
Solution
The fix is to replace this logic and explicitly check for a newer Published version only.
Replace the existing code:
var latest = kbViewModel.getLatestAccessibleVersionFromId(knowledgeRecord.article_id);
var newVersionAvailable = !gs.nil(latest) &&
(latest.getValue('version') != knowledgeRecord.getValue('version'));
With the following:
var newVersionAvailable = false;
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('number', knowledgeRecord.number);
gr.addQuery('workflow_state', 'published');
gr.addQuery('version', '>', knowledgeRecord.version);
gr.query();
if (gr.hasNext()) {
newVersionAvailable = true;
}
*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
